This error will occur if the Delete Managed Components feature is not be enabled for the Dev Hub where the namespace is registered.
This error will also occur if components are deleted (or added) and a patch version is attempted as patch versions cannot remove existing components or add new components. Only major or minor versions support adding and deleting components.
Another reason for this error is if an unsupported component is being deleted. The Components Available in Second-Generation Managed Packages doc covers which components can be deleted. Find the component type in the list on the left, then locate "Package Developer Can Remove Component From Package". This section will wither state "No", "Yes", or "Yes" with additional conditions. For example, Apex Class states "Yes (if not set to global access).". If a component cannot be deleted, the only workaround is to branch from a previous version that was created before the component was added. If there are no previous verisons, eg the component was added in version 1.0, then a new package will have to be created.
If the Delete Managed Components feature is not enabled for your Dev Hub org, please contact Support to enable this feature. We will need the following to do so:
As this is a powerful feature, please provide the following acknowledgments and details:
1. I have read the section below on this feature from the ISVForce Guide to understand the usability, best practices, limitations, as well as what components are available to delete (both docs apply to 1GP and 2GP).
Deleting Components in Managed Packages
Second-Generation Managed Packaging Developer Guide
2. What is the Dev Hub Org ID where you would like this feature enabled?:
3. What is an Admin User's Username or User ID for the Dev Hub Org?
Salesforce package versions follow a major.minor.patch numbering scheme. Patch versions are designed for bug fixes only and do not allow adding or removing components. To include component changes, you must explicitly create a minor or major version
If you have added or deleted components, the error occurs because the system defaults to creating a patch version, which does not support these changes.
To fix this, re-run the sf package version create command, but this time, explicitly specify a new minor or major version using the --version-number flag.
Example Solution:
Failed Command (causes the error): sf package version create --package "My Package Name" --installation-key-bypass
Corrected Command (resolves the error): sf package version create --package "My Package Name" --version-number 1.3.0.NEXT --installation-key-bypass
By adding --version-number 1.3.0.NEXT, you are creating a new minor version that correctly accepts your component changes.
002903316

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.