6

We're trying to create a nested package structure to keep our code organized. So far, we have a design that looks like this:

core
  ^-- utils
  |     ^---- marketing
  |     ^---- support
  |     ^---- ...etc...
  ^-- integrations

We've created the "core" and "utils" package, but when trying to create a package version for "marketing", we are told that we need to install the dependency "core" in order for the version to be uploaded.

Is this indeed a requirement? Does this happen because we specified both core and utils as a dependency? Is there any way to get this to work without committing to installing a package in production?

sfdx-project.json

{
    "packageDirectories": [
    {
        "path": "force-app/core/",
        "package": "base",
        "versionName": "ver 0.1",
        "versionNumber": "0.1.0.NEXT",
        "default": true
        "definitionFile": "config/org-definition.json"
    },
    {
        "path": "force-app/utils/",
        "package": "utils",
        "versionName": "ver 0.1",
        "versionNumber": "0.1.0.NEXT",
        "default": false,
        "definitionFile": "config/org-definition.json",
        "dependencies": [
            {
            "package": "base",
            "versionNumber": "0.1.0.LATEST"
            }
        ]
    },
    {
        "path": "force-app/marketing/",
        "package": "marketing",
        "versionName": "ver 0.1",
        "versionNumber": "0.1.0.NEXT",
        "default": false,
        "definitionFile": "config/org-definition.json",
        "dependencies": [
            {
                "package": "utils",
                "versionNumber": "0.1.0.LATEST"
            },
            {
                "package": "base",
                "versionNumber": "0.1.0.LATEST"
            }
        ]
    },
    "namespace": "",
    "sfdcLoginUrl": "https://login.salesforce.com",
    "sourceApiVersion": "46.0",
    "packageAliases": [
    // ... snipped ... //
    ]
}

When we created "core", there was no problems. Then, we created "utils", again with no problem. Now, trying to create the third package, "marketing", we get the following:

An error occurred while trying to install a package dependency, ID XXXX: The package you're installing depends on package "core", version "0.1". Install package "core" in the target org before you install "utils".

1 Answer 1

6

After carefully checking the JSON source, I realized that the dependencies were out of order. You must list the dependencies in the order that they depend upon each other.

In other words, the (incorrect) source looked like:

    "dependencies": [
        {
            "package": "utils",
            "versionNumber": "0.1.0.LATEST"
        },
        {
            "package": "base",
            "versionNumber": "0.1.0.LATEST"
        }
    ]

Instead of the correct dependency order:

    "dependencies": [
        {
            "package": "base",
            "versionNumber": "0.1.0.LATEST"
        },
        {
            "package": "utils",
            "versionNumber": "0.1.0.LATEST"
        }
    ]

You must log in to answer this question.

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