10

My sfdx-project.json looks like this:

{
    "packageDirectories": [
        {
            "path": "force-app",
            "package": "my package",
            "versionName": "ver 0.3",
            "versionNumber": "0.3.0.NEXT",
            "definitionFile": "config/project-scratch-def.json",
            "ancestorId": "v2-id"
        }
    ],
    "namespace": "my_namespace",
    "sfdcLoginUrl": "https://login.salesforce.com",
    "sourceApiVersion": "48.0",
    "packageAliases": {
        "my package": "package-id",
        "my [email protected]": "v1-id",
        "my [email protected]": "v2-id"
    }
}

So going from 0.1.0.1 to 0.2.0.1 (v1-id to v2-id) was fine. It let me install v2 and update it from v1. Now I need a patch as I just made a few changes, so trying to patch off of v2. It packages and I can promote, then when I go to install in an org with no package yet at all (so clean install) I get the following error:

Encountered errors installing the package!,Installation errors:

  1. Cannot install component of type:Layout named:my_metadata__mdt-my metadata Layout subjectId:some-id because it was used as a scratch org ancestor., Details: package.xml: Cannot install component of type:Layout named:my_metadata__mdt-my metadata Layout subjectId:some-id because it was used as a scratch org ancestor.

Does this have to do with the definitionFile in the packageDirectories? I can't really find any information on this error from searching around. Does anyone know what this means and how to fix?

2 Answers 2

19

I just ran into the same issue. Trying to install my namespaced package into a scratch org with the same namespace.

You need to create a scratch org without a namespace using the --nonamespace flag and install your packages in there.

Namespaced scratch orgs should be used for development work on a package.

Non-namespaced scratch orgs should be used for testing installs of your package.

1
  • 1
    The actual flag is --no-namespace
    – Math M.
    Commented Feb 1 at 19:46
1

Expanding on the answer of RockPile, in Salesforce docs it says:

Create a scratch org for user acceptance testing or to test installations of packages. In this case, you don’t want to create a scratch org with a namespace.

So we use the --no-namespace flag:

sf org create scratch --definition-file config/project-scratch-def.json --no-namespace --duration-days 7  --alias mySO

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .