1

I'm working on "Unlocked Packages for Customers" trailhead module. While creating the package version I'm getting below error: ERROR: The --path (-d) value, [force-app], and --package (-p) value, [th-dreamhouse], were both found in sfdx-project.json but don’t match. If you supply both values, they must match the path and package values in one of the packageDirectories.

My sfdx command: sfdx force:package:version:create -p th-dreamhouse -d force-app -k test1234 --wait 10 -v DevHub

My sfdx-project.json file:

{
    "packageDirectories": [
        {
            "path": "force-app",
            "default": true,
            "package": "dreamhouse",
            "versionName": "ver 1.0",
            "versionNumber": "1.0.0.NEXT"
        },
        {
            "path": "force-app",
            "package": "th-dreamhouse",
            "versionName": "ver 1.0",
            "versionNumber": "1.0.0.NEXT",
            "default": false
        }
    ],
    "namespace": "",
    "sfdcLoginUrl": "https://login.salesforce.com",
    "sourceApiVersion": "44.0",
    "packageAliases": {
        "dreamhouse": "0Ho0I000000PAscSAG",
        "[email protected]": "04t0I000001E1xdQAC",
        "th-dreamhouse": "0Ho0I000000PAshSAG"
    }
}

3 Answers 3

11

This error is occurring because you have two different packages using the force-app path. Since you're specifying both -d and -p in your command the path you provide for the -d flag has to match up with path for the package you provide with the -p flag. But your path is used for both dreamhouse and th-dreamhouse, so your path doesn't actually match up with the package provided.

Is there a reason you have force-app used for both packages? It seems like that's an error and if you either remove the dreamhouse package from your json file (if it's unnecessary) or set a different path for it then you should stop receiving that error.

1
  • Just an addition to this, for any other package with same path, modify that path to nested path like force-app/main/default and then try again. The path for other package that you changed just now, need to be a valid path May 11, 2022 at 10:59
2

Other solution that I test here: Duplicate directory force-app with other name how force-app-2

Try this command change directory. sfdx force:package:version:create -p th-dreamhouse -d force-app2 -k test1234 --wait 10 -v DevHub

Works for me, tks

0

I removed this part from the sfdx-project.json file

{
            "path": "force-app",
            "default": true,
            "package": "dreamhouse",
            "versionName": "ver 1.0",
            "versionNumber": "1.0.0.NEXT"
        },

And it worked .

**One path cannot be used by more than one package **

And be sure to change the default attribute to true !!

{
            "path": "force-app",
            "package": "th-dreamhouse",
            "versionName": "ver 0.1",
            "versionNumber": "0.1.0.NEXT",
            "default": true
        }

You must log in to answer this question.

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