I created a package and now I want to create a dependent package. Let's say the parent package has a custom object: namespace__Application__c

In my child package, under the objects directory, I have: namespace__Application__c/fields/

which is a directory of new fields to be added to the object.

When I try to install the package, I get the following error:

package.xml: Cannot add component of type:CustomObject named:namespace__Application__c subjectId:01IP0000000Iz59 to another package because it is an installed component.

The parent package is already installed and the child package gets compiled with no errors, but this happens when I try to install it.

I can only find one more result here but it's a different problem.

Details about the environment:

  1. Both packages are attached to the same dev hub
  2. Both packages created with this command: sfdx force:package:version:create --package PackageName --path force-app --installationkey XXXXX --wait 10 --definitionfile config/project-scratch-def.json
  3. I'm trying to install them to a temporary scratch org - the parent package installs fine, the child package fails

Here's the sfdx-project.json

    "packageDirectories": [
            "path": "force-app",
            "default": true,
            "package": "ChildPackage",
            "versionName": "ver 0.2",
            "versionNumber": "0.2.0.NEXT",
            "dependencies": [
                    "package": "ParentPackage@0.1.0-9"
    "namespace": "namespace",
    "sfdcLoginUrl": "https://login.salesforce.com",
    "sourceApiVersion": "47.0",
    "packageAliases": {
        "ChildPackage": "0HoXXX",
        "ParentPackage@0.1.0-9": "04tXXX",
        ... multiple versions of ChildPackage ...
        "ChildPackage@0.1.0-15": "04tXXX"
  • What are the orgs involved here - where are you trying to install this second package? Are you using 1GP or 2GP?
    – David Reed
    Mar 2, 2020 at 19:51
  • @DavidReed I believe it's 2GP - it's an unlocked package. Added more details in the main post
    – Rai
    Mar 2, 2020 at 20:10
  • What's your sfdx-project.json file look like? Did you actually list the parent package as a dependency?
    – sfdcfox
    Mar 2, 2020 at 20:59
  • @sfdcfox I updated the post with the sfdx-project.json
    – Rai
    Mar 2, 2020 at 23:19

1 Answer 1


For your 2GP packages, you need to use the name/versionNumber format for your dependencies:

"dependencies": [
        "package": "ParentPackage",
        "versionNumber": "0.1.0.LATEST"

It took me a little while to figure this out myself.

Also, make sure you do not have an object-meta.xml file in the root of each object folder for the child packages. It should contain only field metadata.

  • Wow, you are right! It seemed to have worked. I would have never caught that. Thank you!
    – Rai
    Mar 3, 2020 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.