Loading

Error: "We couldn’t create this package version because new components were added or existing components were deleted" when creating a new 2GP version

Date de publication: Apr 8, 2026
Description

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.

Résolution

Workaround 1

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?

 

Workaround 2 - For Adding/Deleting Components in a Patch Version 

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.

 

Numéro d’article de la base de connaissances

002903316

 
Chargement
Salesforce Help | Article