Repository navigation
Conversation
|
Warning Review limit reached
Next review available in: 2 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (10)
📝 WalkthroughWalkthroughChangesPackage manager dependency synchronization
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant CLI
participant PreCommand
participant EnvLockfile
participant InstallPipeline
CLI->>PreCommand: Build pre-command plan
PreCommand->>InstallPipeline: Check whether pipeline syncs lockfile
PreCommand->>EnvLockfile: Check packageManagerDependencies
EnvLockfile-->>PreCommand: Return sync-needed status
PreCommand-->>CLI: Execute switch or lockfile sync
Assessment against linked issues
Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by QodoFix pre-command env-lockfile sync for pinned pnpm on all commands
AI Description
Diagram
High-Level Assessment
Files changed (9)
|
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the previously raised lockfile-disable concern is invalid because both pnpm implementations intentionally persist package-manager dependencies without a use-lockfile gate. Reviews (4): Last reviewed commit: "fix(cli): record packageManagerDependenc..." | Re-trigger Greptile |
Code Review by Qodo
Context used✅ Compliance rules (platform):
24 rules 1.
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
Thanks — one of the three led to a real fix, in c02f9f8. Taking them in turn. 2. Full lockfile parse on startup — fixed, and it was worse than described. The read itself has to stay: it is what lets the common case cost nothing else. Without knowing what the lockfile records, every command in a pinned project would have to build a resolver and go to the registry to find out. One lockfile read is the cheap answer, not the expensive one. But the review made me look at the path again, and the download policy — the default for The parsed lockfile is now threaded into the sync decision: match &target.source {
SwitchSource::LockedEnv { env, .. } => ReadEnvLockfile::Already(env),
SwitchSource::Resolve { .. } => ReadEnvLockfile::NotYet,
}
1. Unsanitized path in error — not sanitizing, but the duplication is gone. The sanitize boundary in this module is drawn around manifest-derived strings — the package manager name and the wanted version range, which come from a repository the user has only cloned. Worth noting the flagged string is not new: 3. Symlink lockfile read DoS — declined, deliberately. Reading a lockfile through a symlink is a decision the project made on purpose, not an oversight: #13073 restored it because Bazel and Nix stage The exposure is also not new here. Written by an agent (Claude Code, claude-opus-5). |
Micro-Benchmark ResultsLinux |
|
Code review by qodo was updated up to the latest commit c02f9f8 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pnpm/crates/cli/src/cli_args/package_manager.rs (1)
33-41: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse
PmOnFail::as_str()forpackage_manager_to_sync.
package_manager.rs:39-40convertson_failwith the same match values already inpacquet_config::PmOnFail::as_str()andpre_command.rs's helper. Reuse the inherent method and removeon_fail_strfrompre_command.rsso this mapping has one source of truth.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pnpm/crates/cli/src/cli_args/package_manager.rs` around lines 33 - 41, Update package_manager_to_sync to use PmOnFail::as_str() when assigning pm.on_fail, and remove the redundant on_fail_str helper from pre_command.rs. Preserve the existing option handling and string values while making PmOnFail::as_str the single mapping source.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pnpm/crates/cli/src/cli_args/package_manager.rs`:
- Around line 33-41: Update package_manager_to_sync to use PmOnFail::as_str()
when assigning pm.on_fail, and remove the redundant on_fail_str helper from
pre_command.rs. Preserve the existing option handling and string values while
making PmOnFail::as_str the single mapping source.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: c99ee563-eb4a-4d04-8d87-1b587cd6d327
📒 Files selected for processing (9)
.changeset/sync-package-manager-deps-on-every-command.mdpnpm/crates/cli/src/cli_args/package_manager.rspnpm/crates/cli/src/cli_args/pipelines.rspnpm/crates/cli/src/cli_args/pre_command.rspnpm/crates/cli/src/cli_args/pre_command/tests.rspnpm/crates/cli/src/cli_args/tests.rspnpm/crates/cli/src/lib.rspnpm/crates/cli/tests/package_manager_check.rspnpm/crates/config/src/lib.rs
|
Two new findings in the updated review, plus CodeRabbit's nitpick — all addressed in 54652ff.
The side effect is not new, and the version flag is not a read-only command today. What this PR adds to that path is the smaller half: recording the pin when no download is needed. Taking the suggested fix would make Since it is a real behavioral decision, it now has a test rather than only a comment: If Changeset missing
CodeRabbit's nitpick — accepted. Right, and it was my own leftover: adding Written by an agent (Claude Code, claude-opus-5). |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@pnpm/crates/cli/tests/version.rs`:
- Around line 85-90: Update the lockfile assertion in the version test to parse
pnpm-lock.yaml as YAML and inspect the packageManagerDependencies mapping
directly. Assert that this mapping contains the expected pinned package-manager
entry, rather than independently checking broad string containment; retain the
existing failure context showing the written lockfile.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 3d14db5f-3793-42c4-96d0-3b5667f8561a
📒 Files selected for processing (10)
.changeset/sync-package-manager-deps-on-every-command.mdpnpm/crates/cli/src/cli_args/package_manager.rspnpm/crates/cli/src/cli_args/pipelines.rspnpm/crates/cli/src/cli_args/pre_command.rspnpm/crates/cli/src/cli_args/pre_command/tests.rspnpm/crates/cli/src/cli_args/tests.rspnpm/crates/cli/src/lib.rspnpm/crates/cli/tests/package_manager_check.rspnpm/crates/cli/tests/version.rspnpm/crates/config/src/lib.rs
🚧 Files skipped from review as they are similar to previous changes (8)
- .changeset/sync-package-manager-deps-on-every-command.md
- pnpm/crates/config/src/lib.rs
- pnpm/crates/cli/src/lib.rs
- pnpm/crates/cli/src/cli_args/package_manager.rs
- pnpm/crates/cli/tests/package_manager_check.rs
- pnpm/crates/cli/src/cli_args/pipelines.rs
- pnpm/crates/cli/src/cli_args/pre_command/tests.rs
- pnpm/crates/cli/src/cli_args/pre_command.rs
|
Code review by qodo was updated up to the latest commit 54652ff |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
pnpm's pre-command block calls syncEnvLockfile for every command that isn't in skipPackageManagerCheckForCommand, so a project pinning pnpm through devEngines.packageManager (or a v12+ packageManager field) gets its packageManagerDependencies recorded whatever the user ran. pacquet synced only from the install-family pipelines, so `pnpm list` in a fresh clone left no lockfile behind. pre_command_plan now returns a PreCommandPlan — either the version switch it already planned, or the env-lockfile sync it needs — and lib.rs runs whichever came back on the pre-command runtime. The sync is planned in the same two places pnpm reaches syncEnvLockfile: after checkPackageManager on the warn/error/corepack path, and on the download path when the running pnpm already satisfies the pin (where pnpm's switchCliVersion still resolves and saves before returning). The install family is excluded, because it passes its own frozen-lockfile value to the sync and pacquet — unlike pnpm — fails a frozen install whose packageManagerDependencies are out of date. Syncing those commands from the pre-command block would repair the lockfile before the pipeline could refuse to. Excluding them also keeps the up-to-date install fast path free of the lockfile read. The plan is skipped without touching the network whenever the env lockfile already records a version satisfying the pin. That answer needs the lockfile, but the download path has already read it looking for a version to switch to, and `pnpm-lock.yaml` is read whole — so the parsed lockfile is threaded into the sync decision rather than read a second time. A warm pinned project pays one lockfile read per command, the same as before. package_manager_to_sync now takes the effective pmOnFail rather than reading the manifest's own onFail, matching how pnpm resolves wantedPackageManager.onFail before shouldPersistLockfile sees it. Closes #13348 Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Code review by qodo was updated up to the latest commit 25bc1f3 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
|
Heads-up on the one red check: Code Coverage is failing repo-wide right now, not because of this PR. Same signature everywhere — the job dies about 5–6 minutes in with the
The Written by an agent (Claude Code, claude-opus-5). |
…13382) pnpm's pre-command block calls syncEnvLockfile for every command that isn't in skipPackageManagerCheckForCommand, so a project pinning pnpm through devEngines.packageManager (or a v12+ packageManager field) gets its packageManagerDependencies recorded whatever the user ran. pacquet synced only from the install-family pipelines, so `pnpm list` in a fresh clone left no lockfile behind. pre_command_plan now returns a PreCommandPlan — either the version switch it already planned, or the env-lockfile sync it needs — and lib.rs runs whichever came back on the pre-command runtime. The sync is planned in the same two places pnpm reaches syncEnvLockfile: after checkPackageManager on the warn/error/corepack path, and on the download path when the running pnpm already satisfies the pin (where pnpm's switchCliVersion still resolves and saves before returning). The install family is excluded, because it passes its own frozen-lockfile value to the sync and pacquet — unlike pnpm — fails a frozen install whose packageManagerDependencies are out of date. Syncing those commands from the pre-command block would repair the lockfile before the pipeline could refuse to. Excluding them also keeps the up-to-date install fast path free of the lockfile read. The plan is skipped without touching the network whenever the env lockfile already records a version satisfying the pin. That answer needs the lockfile, but the download path has already read it looking for a version to switch to, and `pnpm-lock.yaml` is read whole — so the parsed lockfile is threaded into the sync decision rather than read a second time. A warm pinned project pays one lockfile read per command, the same as before. package_manager_to_sync now takes the effective pmOnFail rather than reading the manifest's own onFail, matching how pnpm resolves wantedPackageManager.onFail before shouldPersistLockfile sees it. Closes pnpm#13348
The install loaded only the global and project pnpmfiles, so a config dependency plugin's pnpmfile contributed its updateConfig hook and nothing else. Its readPackage, afterAllResolved and custom resolvers never ran, and pnpmfileChecksum left it out. pnpm 11 puts plugin pnpmfiles in the same requireHooks set as the project's. PnpmfileSelection now carries the config dependencies, and find_pnpmfiles returns the global pnpmfile, then the installed plugin pnpmfiles, then the project's own, which is pnpm 11's order. Every consumer of the selection now sees the same set: install, update, deploy, the lockfile freshness checks, the optimistic repeat-install state, and the updateConfig/beforePacking pass. The updateConfig pass used to run plugins ahead of the global pnpmfile and now runs them after it, as pnpm 11 does. The up-to-date fast path already bails out whenever config dependencies exist, so it is unaffected. The workspace state's pnpmfile list now includes plugin pnpmfiles, as pnpm 11's does. A state written before this change therefore triggers one re-validation. Closes pnpm/pnpm#12366. Its env-lockfile items were already fixed by #13382, #13346 and #13436. This was the last lockfile divergence found while verifying them. --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Summary
Closes #13348.
pnpm records the pinned pnpm version under
packageManagerDependenciesfrom itspre-command block, so every command writes it. pacquet only did so from the
install-family pipelines, so a project whose first pacquet command was
pnpm list(orrun,exec,why, …) got no lockfile at all.The issue lists three ways out. This PR takes the first one — keep pacquet's
extra strictness and gate the pre-command sync — because the alternative
(dropping
FrozenLockfileOutdatedfor package-manager deps to match pnpmexactly) gives up a real guard against a lockfile silently changing under
--frozen-lockfilein CI, and the third (record the divergence) leaves thelockfile dependent on which command ran first.
The gate is the command itself rather than the effective
frozen-lockfilevalue: the install family (
install,ci,add,update,remove,dedupe,prune,deploy,unlink,install-test) already syncs from its ownpipeline, where the
frozen-lockfilevalue is known, so the pre-command blockskips those and covers everything else. A frozen install therefore still fails
on an out-of-date
packageManagerDependenciesinstead of having it repairedfirst, and
pacquet install's up-to-date fast path keeps its zero-networkstartup.
Two more spots the pre-command block now mirrors pnpm:
downloadpolicy with a pin the running pnpm already satisfies. pnpm getsthere through
switchCliVersion, which resolves and saves before it decidesno switch is needed; pacquet returned early and wrote nothing. This is the
issue's reproduction.
pmOnFail. pnpm resolveswantedPackageManager.onFailagainst the settingbefore
shouldPersistLockfilereads it, so--pm-on-fail=ignorekeeps thepin out of the lockfile and
--pm-on-fail=warnputs a manifest-ignored pinback in.
package_manager_to_syncnow takes the effective policy, which fixesthe install family too.
Rebased onto
mainafter #13380 landed the same "pass the parsedmanifest" refactor of
package_manager_to_sync, which shrank this diff to justthe
on_failparameter on that function.pacquet-only: the TypeScript CLI already behaves this way, and nothing about its
behavior changes here.
Squash Commit Body
Checklist
pnpm/port, or the description notes what still needs porting.pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Written by an agent (Claude Code, claude-opus-5).
Summary by CodeRabbit
devEngines.packageManagerare now recorded inpnpm-lock.yamlfor every pnpm command, including commands outside the install family.--versionflow now records the pinned package manager when it matches the current pinned pnpm.pmOnFail(warn vs ignore), and avoids updatingpnpm-lock.yamlwhen it’s already up to date.pmOnFailsettings.