Repository navigation
Conversation
… peer #13351 reported that a workspace-root dependency installed from git under an alias could not satisfy another importer's peer of the package's real name, so `resolvePeersFromWorkspaceRoot` silently resolved a second copy from the registry. It does not reproduce: both git shapes (a `type: git` repository and a `gitHosted: true` host archive) dedupe onto the root's dependency, and the TypeScript CLI produces a byte-identical lockfile for the same fixture. The report read `build_resolve_result` in `git_resolver.rs`, which sets `name_ver: None` and `manifest: None`, and concluded a git resolution reaches the hoist loop unnamed. `resolve_impl` then calls `read_package_metadata`, which fills `manifest` from the package's own `package.json` — a host archive is downloaded and read, a repository with no archive endpoint gets a throwaway checkout — so `resolved_pkg_name` names the dependency before the hoist loop ever sees it. The bare shape belongs to the no-fetch-context path used by unit tests and the resolve-only NAPI entry point, neither of which hoists peers. Lockfile reuse is named too: `synthesize_reused_result` reconstructs the manifest from the recorded snapshot key. The doc on `resolved_pkg_name` claimed the opposite, and is what the report was reading; it now describes what the resolvers actually deliver. The new end-to-end test pins the behavior against a local git repository whose package name differs from the alias the root installs it under; it was verified to fail — with the duplicate registry copy the issue describes — when `resolved_pkg_name`'s manifest fallback is removed. Closes #13351. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdds regression coverage for aliased git-root peer resolution and clarifies when ChangesAliased git peer resolution
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 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 QodoAdd e2e coverage for aliased git root deps satisfying peers
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the prior comment concern was addressed by removing the scenario narration while retaining the non-obvious resolver rationale. Reviews (3): Last reviewed commit: "test(cli): re-resolve with the prior loc..." | 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. |
Micro-Benchmark ResultsLinux |
…the fetch context Both resolvers only read the package's `package.json` when they hold a fetch context; the resolve-only chain wires none and leaves `manifest` unset, so "arrives named" is not unconditional. It holds where it matters — every install path wires one, and the context-less chain hoists no peers — but the doc should not assert an invariant the type does not carry. The new test's doc comment also restated its own setup and assertions; what a reader can't recover from the body is why a git dep is nameable at hoist time at all, so only that stays. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Both review findings addressed in 2a5a854. Qodo — "Overstated naming invariant". Correct, and the fix is worth having. The doc asserted that git and remote-tarball resolutions "arrive named" unconditionally; both resolvers only read the package's /// `name_ver`, else the manifest — the canonical name for the protocols
/// that leave `name_ver` unset. The git and remote-tarball resolvers fill
/// `manifest` from the package's own `package.json` during resolution
/// whenever they hold a fetch context, which every install path wires, so
/// those arrive named too. `None` when no manifest name is available: a
/// repository with no `package.json`, or the resolve-only chain that
/// wires no fetch context — and hoists no peers.
That last clause is why the gap is not reachable in practice rather than merely unobserved: the only chain that leaves a git resolution unnamed is the single-package resolve path, which never runs the hoist loop Greptile — test comment duplicates behavior. Agreed; replied on the thread. The scenario restatement is gone, the why stays.
Written by an agent (Claude Code, claude-opus-5). |
|
Code review by qodo was updated up to the latest commit 2a5a854 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
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/git_hosted_install.rs`:
- Around line 604-650: Expand
an_aliased_git_root_dependency_provides_another_importers_peer to cover both the
regular Git locator and the gitHosted: true archive locator, preserving the
existing peer assertions for each variant. After the first successful install,
rerun install without changing inputs and compare the raw pnpm-lock.yaml bytes
to verify lockfile reuse is byte-identical. Add or reference equivalent
TypeScript pnpm coverage so both test suites exercise the same locator and reuse
matrix.
🪄 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: 271c8307-4e6b-4879-8c6b-e5f6ed881be1
📒 Files selected for processing (2)
pnpm/crates/cli/tests/git_hosted_install.rspnpm/crates/resolving-deps-resolver/src/resolve_importer.rs
…r test Every install after the first re-resolves with the recorded lockfile in hand, and that is the shape a workspace spends its life in; the test only covered a first install. A second run under `--no-prefer-frozen-lockfile` must leave the lockfile byte-identical, so the peer cannot drift onto a registry copy on any later install. The issue reference loses its "reported as broken" framing: what the comment is for is why a git dep is nameable at hoist time, and the link carries the rest. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Code review by qodo was updated up to the latest commit f5a0b62 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
… peer (pnpm#13392) pnpm#13351 reported that a workspace-root dependency installed from git under an alias could not satisfy another importer's peer of the package's real name, so `resolvePeersFromWorkspaceRoot` silently resolved a second copy from the registry. It does not reproduce: both git shapes (a `type: git` repository and a `gitHosted: true` host archive) dedupe onto the root's dependency, and the TypeScript CLI produces a byte-identical lockfile for the same fixture. The report read `build_resolve_result` in `git_resolver.rs`, which sets `name_ver: None` and `manifest: None`, and concluded a git resolution reaches the hoist loop unnamed. `resolve_impl` then calls `read_package_metadata`, which fills `manifest` from the package's own `package.json` — a host archive is downloaded and read, a repository with no archive endpoint gets a throwaway checkout — so `resolved_pkg_name` names the dependency before the hoist loop ever sees it. The bare shape belongs to the no-fetch-context path used by unit tests and the resolve-only NAPI entry point, neither of which hoists peers. Lockfile reuse is named too: `synthesize_reused_result` reconstructs the manifest from the recorded snapshot key. The doc on `resolved_pkg_name` claimed the opposite, and is what the report was reading; it now describes what the resolvers actually deliver. The new end-to-end test pins the behavior against a local git repository whose package name differs from the alias the root installs it under; it was verified to fail — with the duplicate registry copy the issue describes — when `resolved_pkg_name`'s manifest fallback is removed. Closes pnpm#13351.
Summary
#13351 reports that a workspace-root dependency installed from git under an alias cannot satisfy another importer's peer of the package's real name, so
resolvePeersFromWorkspaceRootsilently resolves a second copy from the registry. It does not reproduce. This PR pins the working behavior with an end-to-end test and corrects the doc comment the report was reading.What was actually checked
A two-importer workspace — root declares the git package under a different alias, a sibling project depends on something that peers on the package's real name — resolved against a locally built binary:
git+file://repository (type: gitresolution)github:host archive (gitHosted: truetarball)Why the report read the other way
It quotes
build_resolve_resultingit_resolver.rs, which does setname_ver: Noneandmanifest: None. Butresolve_implthen callsread_package_metadata, which fillsmanifestfrom the package's ownpackage.json— a git host's archive is downloaded and read, a repository with no archive endpoint gets a throwaway checkout (#13059). Soresolved_pkg_namenames a git dependency well before the hoist loop reads it, and the alias-only match the issue describes never happens. The bare shape belongs to the no-fetch-context path used by unit tests and the resolve-only NAPI entry point, neither of which hoists peers. The lockfile-reuse path carries a name of its own too —synthesize_reused_resultreconstructs the manifest from the recorded<name>@<url>snapshot key — though a direct git dep does not reach it on re-resolution:--no-prefer-frozen-lockfilere-resolves it against the repository, which is where the name comes from again.That means option 1 in the issue (read the name from the wanted lockfile) is unnecessary, and the first-install gap it would have left does not exist either.
The one genuinely nameless case is a repository with no
package.json, where the alias is the only name anywhere in the graph — thewith-non-package-depfixture shape, and identical in both stacks.Closes #13351.
Squash Commit Body
Checklist
pnpm/port, or the description notes what still needs porting.No behavior changes in either stack. The TypeScript CLI was run against the
same fixture and produces a byte-identical lockfile, so there is nothing to
port; the new coverage lives on the pacquet side, where the defect was reported.
Added a changeset— nothing user-visible changes: a test and a doc comment.an_aliased_git_root_dependency_provides_another_importers_peerinpnpm/crates/cli/tests/git_hosted_install.rs. Verified to catch the reportedregression: with
resolved_pkg_name's manifest fallback removed it fails with1.0.0(@scoped/[email protected])— the second registry copy — instead of the git key.It also re-installs under
--no-prefer-frozen-lockfileand asserts the lockfileis byte-identical, covering the shape every install after the first takes.
Not covered here: the
gitHosted: truearchive locator needs a real githost, and every test in this file is deliberately network-free over
git+file://(see the module doc); that shape is pinned at the resolver levelin
pacquet-resolving-git-resolver. It was verified by hand againstgithub:kevva/is-negative#1d7e288— it dedupes onto the root's dep identically.The
resolved_pkg_namedoc no longer claims a git resolution reaches thehoist loop unnamed.
Verification
just readygreen on the final state: 7217 tests passed, 0 failures;cargo clippy --locked --workspace --all-targets -- --deny warningsclean;typos,cargo fmt,cargo checkclean.The Pacquet Code Coverage check is red, and is unrelated to this PR: the same job is failing on
mainand on every sibling branch in the same window, with no job logs retained.Written by an agent (Claude Code, claude-opus-5).