Sub topic 14
Troubleshooting common dependency and version errors
This chapter assumes you can read sfdx-project.json, run sf package commands, and know the difference between beta and released versions. Most failures come from a small set of causes. Check them in a fixed order and you will usually find the problem quickly.
Start with the symptom
Error text varies by CLI and API version, so match on the cause rather than the exact wording.
Errors when creating a version
Dependency not found. Every package name used in dependencies must have an entry in packageAliases. For a pinned dependency such as [email protected], the alias must map to a 04t ID. A missing or misspelled alias is the most common cause.
Wrong directory order. A package must appear in packageDirectories after the packages it depends on. If Sales App is listed before Utils, version creation can fail even though both are defined.
No matching version for LATEST. [email protected] resolves to the highest build of 1.1.0. If no 1.1.0 version exists yet, nothing matches. Create it first, or lower the requested version.
Errors when promoting
Promotion fails in two typical cases:
- The version was created without
--code-coverage, or coverage is below 75 percent. - A dependency is still a beta. A version you promote must depend only on released versions.
Check a dependency's state before you promote.
sf package version list --packages Utils --target-dev-hub myDevHub
sf package version report --package "[email protected]" --target-dev-hub myDevHubThe IsReleased field in the report tells you whether it is a beta.
Errors when installing
Dependency missing in the target org. Installing Sales App fails if Utils at a compatible version is not already there. List what the org has.
sf package installed list --target-org myOrgInstall Utils first, then Sales App.
Beta in the wrong org. Beta versions cannot be installed in production. Promote the version, or install into a scratch org or sandbox.
Version already newer. You cannot install a lower version over a higher one. Choose a version at or above the one installed.
Errors when upgrading
Upgrades can fail because of the version's ancestry or because of changes you made between versions.
- A new version must have a higher number than its ancestor.
- Removing or changing certain components that a released version contains is blocked. Managed packages have stricter limits than unlocked ones.
- A subscriber org that has not installed the intermediate version a dependency expects can fail to upgrade.
A checklist that works
- Read the full error and note whether it came from create, promote, or install.
- Confirm every dependency has a
packageAliasesentry. - Confirm dependencies come first in
packageDirectories. - Confirm each dependency version you rely on is released if you are promoting or targeting production.
- Confirm the target org already has the dependencies installed at compatible versions.
If you pinned a dependency and the build still fails, replace the pin with LATEST temporarily. If that works, the pinned 04t ID is stale or wrong.
Exercise
You run sf package version promote on Sales [email protected]. It fails. The report for its dependency [email protected] shows IsReleased: false. What do you do, and in what order?
Show answer
Promote [email protected] first, after confirming its code coverage is at least 75 percent. Then rebuild or re-check Sales App if needed, and promote it. A version you promote can depend only on released versions.
Exercise
An install of Sales App into a sandbox fails because Utils is missing. Which command shows what the org has, and what do you install first?
Show answer
Run sf package installed list --target-org myOrg. Install Utils first, then Sales App, because the dependency must be present before its dependent.