Repository navigation
Description
It took me a while to chase this one down. It wasn't super clear from the documentation whether the original behavior (transitive devDependencies being installed) was intended behavior. If that's indeed not intended, then maybe the docs can also be improved to make it more explicit 😄 .
It's been a bit tricky to get a reproducible sample, as it depends on state of some internal repos. I hope it's sufficient to look into what's happening based on this report, else I can see if I can put some public repos in the right state to reproduce the issue.
Describe the bug
apm install can resolve a different dependency graph depending on whether apm.lock.yaml already exists.
When a lockfile is present, APM replays the exact commit recorded in the lockfile for an unpinned dependency. When the lockfile is removed, APM resolves that same dependency from the current upstream default branch.
If the upstream package changed its dependency manifest between those two commits, the resulting dependency graph can differ significantly even though the consumer's apm.yml did not change.
In practice, this means:
apm installwith an existing lockfile can install extra transitive packages from an older locked commitrm apm.lock.yaml && apm installcan resolve a newer upstream commit and install fewer packages
This makes the two flows observably different in ways that are surprising when the direct dependency in apm.yml is unpinned.
To Reproduce
Steps to reproduce the behavior:
- Create an APM project with an unpinned direct dependency:
dependencies: apm: - owner/repo
- Ensure
owner/repois a public package whoseapm.ymlchanged between two commits such that:- an older commit has a transitive package under
dependencies.apm - a newer commit moved that same package to
devDependencies.apm
- an older commit has a transitive package under
- Generate and commit
apm.lock.yamlwhile it still points at the older commit. - Run:
git reset --hard git clean --force -dfx apm install -v git status --short
- Observe that APM replays the locked commit and installs the transitive package from the older dependency graph.
- Reset again and run:
git reset --hard git clean --force -dfx rm apm.lock.yaml apm install -v git status --short
- Observe that APM resolves the current upstream commit instead, and the transitive package is no longer installed because it now lives under
devDependencies.
Representative logs from the locked run:
[>] Installing dependencies from apm.yml...
Using apm.lock.yaml (N locked dependencies)
owner/repo: locked at <old-sha>
Resolved dependency tree: X direct + Y transitive deps
Representative logs from the fresh run:
[>] Installing dependencies from apm.yml...
Resolved X direct dependencies (no transitive)
Generated apm.lock.yaml with X dependencies
Expected behavior
I expect this behavior to be made explicit and easier to reason about for unpinned dependencies.
At minimum, apm install should make it very clear that:
- with a lockfile, it is replaying the exact old commit from
apm.lock.yaml - without a lockfile, it is resolving the current upstream state
Right now, this can look like a dependency-resolution bug when in reality the dependency graph changed because the locked upstream commit and the newly resolved upstream commit differ.
Environment (please complete the following information):
- OS: macOS
- Python Version: 3.14.6
- APM Version: 0.23.1
- VSCode Version (if relevant): N/A
Logs
APM source inspection shows the relevant behavior:
- lockfile replay path uses the locked commit SHA when no ref drift is detected
- transitive resolution only walks
get_apm_dependencies()and does not walk transitiveget_dev_apm_dependencies()
Representative user-visible logs:
Using apm.lock.yaml (N locked dependencies)
owner/repo: locked at <old-sha>
and:
Resolved X direct dependencies (no transitive)
Additional context
The important detail is that this is easiest to trigger when the direct dependency is unpinned in apm.yml.
With a committed lockfile:
- APM replays the older locked commit
- the older dependency manifest may still expose transitive packages under
dependencies
Without the lockfile:
- APM resolves a newer upstream commit
- the newer dependency manifest may have moved those same packages to
devDependencies
Since APM does not traverse transitive dev dependencies, the two installs produce different results.
This behavior appears to come from the interaction of:
- lockfile replay of exact commits for reproducibility
- unpinned direct dependencies
- upstream manifest changes between commits
- transitive traversal including only production dependencies
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
docs: clarify lockfile transitive-graph determinism (refs #2007) (#2010)