Skip to content

fix(pm): reconcile install-node runtime deps in outdated check#2812

Merged
elrrrrrrr merged 3 commits intonextfrom
fix/pm-install-node-outdated
Apr 20, 2026
Merged

fix(pm): reconcile install-node runtime deps in outdated check#2812
elrrrrrrr merged 3 commits intonextfrom
fix/pm-install-node-outdated

Conversation

@elrrrrrrr
Copy link
Copy Markdown
Contributor

Summary

  • Context::build_deps folds synthetic node-bin-* optionalDependencies into the root lock entry from engines.install-node, but is_pkg_lock_outdated only compared against package.json (which never carries them). Any project using install-node was judged outdated on every install → endless re-resolve loop.
  • Mirror the same injection at comparison time via a small root_optional_with_runtime helper in crates/pm/src/helper/lock.rs.
  • Add test_is_pkg_lock_outdated_install_node_in_sync to pin the behavior.

Test plan

  • cargo test -p utoo-pm helper::lock::tests — 13/13 pass, including the new case
  • cargo fmt + cargo clippy -p utoo-pm --all-targets -- -D warnings --no-deps clean
  • Manual: run ut install twice on a project with "engines": { "install-node": "16" } — second invocation should load the cached lock instead of re-resolving

🤖 Generated with Claude Code

`Context::build_deps` injects synthetic `node-bin-*` optionalDependencies
into the root lock entry from `engines.install-node`, but
`is_pkg_lock_outdated` only compared against package.json (which never
carries them). Any project using `install-node` was judged outdated on
every install, triggering an endless re-resolve loop.

Mirror the same injection at comparison time via
`root_optional_with_runtime`.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the lockfile validation logic to correctly handle synthetic node-bin-* dependencies injected via the engines.install-node configuration. By introducing the root_optional_with_runtime helper, the system now merges these dependencies into the root package's optional dependencies before comparison, ensuring that projects using install-node are not incorrectly flagged as outdated. Feedback suggests exploring more efficient ways to merge these dependencies to avoid cloning the optional_dependencies map.

Comment thread crates/pm/src/helper/lock.rs
Assert `package-lock.json` inode stays constant across two consecutive
`utoo install` runs on an `engines.install-node` project. `save_package_lock`
writes tmp + rename, so any rewrite changes the inode — identical inode is
the strongest signal that the cached lock was reused. Also pattern-match
the 'package-lock.json is outdated' tracing warning to catch subtler
regressions.

Regression guard for the `is_pkg_lock_outdated` / `Context::build_deps`
optionalDependencies asymmetry fixed in the previous commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@elrrrrrrr elrrrrrrr added the A-Pkg Manager Area: Package Manager label Apr 20, 2026
@elrrrrrrr elrrrrrrr marked this pull request as ready for review April 20, 2026 06:55
@elrrrrrrr elrrrrrrr enabled auto-merge (squash) April 20, 2026 07:23
@elrrrrrrr elrrrrrrr merged commit aebc47f into next Apr 20, 2026
24 checks passed
@elrrrrrrr elrrrrrrr deleted the fix/pm-install-node-outdated branch April 20, 2026 07:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Pkg Manager Area: Package Manager

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants