Skip to content

test(cli): cover an aliased git root dep providing another importer's peer - #13392

Merged
zkochan merged 3 commits into
mainfrom
fix-13351
Jul 26, 2026
Merged

zkochan merged 3 commits into
mainfrom
fix-13351

Conversation

@zkochan

@zkochan zkochan commented Jul 26, 2026 •

Copy link
Copy Markdown
Member

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 resolvePeersFromWorkspaceRoot silently 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:

shape result
git+file:// repository (type: git resolution) one copy, the root's; sibling's peer bound to the git key
github: host archive (gitHosted: true tarball) same
repeat install (re-resolve with the prior lockfile) lockfile byte-identical, still one copy
TypeScript CLI, same fixture byte-identical lockfile

Why the report read the other way

It quotes build_resolve_result in git_resolver.rs, which does set name_ver: None and manifest: None. But resolve_impl then calls read_package_metadata, which fills manifest from the package's own package.json — a git host's archive is downloaded and read, a repository with no archive endpoint gets a throwaway checkout (#13059). So resolved_pkg_name names 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_result reconstructs the manifest from the recorded <name>@<url> snapshot key — though a direct git dep does not reach it on re-resolution: --no-prefer-frozen-lockfile re-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 — the with-non-package-dep fixture shape, and identical in both stacks.

Closes #13351.

Squash Commit Body

pnpm/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/pnpm#13351.

Checklist

  • The change is implemented in both the TypeScript CLI and the Rust
    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.
  • Added or updated tests.

    an_aliased_git_root_dependency_provides_another_importers_peer in
    pnpm/crates/cli/tests/git_hosted_install.rs. Verified to catch the reported
    regression: with resolved_pkg_name's manifest fallback removed it fails with
    1.0.0(@scoped/[email protected]) — the second registry copy — instead of the git key.
    It also re-installs under --no-prefer-frozen-lockfile and asserts the lockfile
    is byte-identical, covering the shape every install after the first takes.

    Not covered here: the gitHosted: true archive locator needs a real git
    host, and every test in this file is deliberately network-free over
    git+file:// (see the module doc); that shape is pinned at the resolver level
    in pacquet-resolving-git-resolver. It was verified by hand against
    github:kevva/is-negative#1d7e288 — it dedupes onto the root's dep identically.
  • Updated the documentation if needed.

    The resolved_pkg_name doc no longer claims a git resolution reaches the
    hoist loop unnamed.

Verification

just ready green on the final state: 7217 tests passed, 0 failures; cargo clippy --locked --workspace --all-targets -- --deny warnings clean; typos, cargo fmt, cargo check clean.

The Pacquet Code Coverage check is red, and is unrelated to this PR: the same job is failing on main and on every sibling branch in the same window, with no job logs retained.


Written by an agent (Claude Code, claude-opus-5).

… 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]>
Copilot AI review requested due to automatic review settings July 26, 2026 00:34

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: fc62fb4e-4c61-42d8-b023-22693e759294

📥 Commits

Reviewing files that changed from the base of the PR and between 2a5a854 and f5a0b62.

📒 Files selected for processing (1)
  • pnpm/crates/cli/tests/git_hosted_install.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • pnpm/crates/cli/tests/git_hosted_install.rs

📝 Walkthrough

Walkthrough

Adds regression coverage for aliased git-root peer resolution and clarifies when resolved_pkg_name may return None.

Changes

Aliased git peer resolution

Layer / File(s) Summary
Resolution contract and regression test
pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs, pnpm/crates/cli/tests/git_hosted_install.rs
Updates resolved_pkg_name documentation and verifies that an aliased git-root dependency supplies another importer’s peer through a stable lockfile entry.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

Possibly related PRs

  • pnpm/pnpm#13059 — Relates to git package-name resolution and lockfile key generation used by this test.
  • pnpm/pnpm#13160 — Covers related git alias and importer lockfile resolution behavior.
  • pnpm/pnpm#13169 — Adds related git-hosted peer-aliasing and lockfile reuse coverage.

Suggested labels: product: pacquet

Suggested reviewers: copilot

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix-13351

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Add e2e coverage for aliased git root deps satisfying peers

🧪 Tests 📝 Documentation 🕐 20-40 Minutes

Grey Divider

AI Description

• Add e2e workspace test ensuring git dep alias satisfies another importer’s peer name.
• Assert lockfile dedupes to a single git-sourced package, avoiding registry fallback.
• Clarify resolved_pkg_name docs: git/tarball resolvers usually read manifest during resolution.
Diagram

graph TD
  T["cli/tests/git_hosted_install.rs"] --> C["pacquet install"] --> R["deps resolver"] --> N["resolved_pkg_name"] --> H["resolvePeersFromWorkspaceRoot"] --> L["pnpm-lock.yaml"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Add a resolver unit test for naming/peer matching
  • ➕ Faster execution and less fixture setup
  • ➕ More targeted coverage of resolved_pkg_name/root-dep matching edge cases
  • ➖ May miss real-world lockfile/hoist integration behavior this bug report concerned
  • ➖ Harder to exercise full peer-hoist flow without broader harnessing
2. Implement lockfile-based name inference for git deps (as suggested in issue)
  • ➕ Would guarantee a name even if metadata fetch were skipped in some path
  • ➖ Adds complexity and more state coupling to lockfile shape
  • ➖ PR analysis indicates the feared unnamed path is not used during peer hoisting

Recommendation: Current approach is best: keep behavior unchanged, pin it with an end-to-end regression test that exercises the actual hoist/lockfile pipeline, and fix the misleading documentation that prompted the report. A unit test could complement this later, but shouldn’t replace the integration coverage.

Files changed (2) +59 / -2

Tests (1) +54 / -0
git_hosted_install.rsAdd e2e test for aliased git root dep satisfying a peer by real name +54/-0

Add e2e test for aliased git root dep satisfying a peer by real name

• Adds a new workspace fixture test where the root depends on a git repo under an alias and a sibling project depends on a package that peers on the repo’s real name. Validates the lockfile binds the peer to the root’s git key and that only a single package entry exists (no registry fallback).

pnpm/crates/cli/tests/git_hosted_install.rs

Documentation (1) +5 / -2
resolve_importer.rsCorrect 'resolved_pkg_name' docs for git/tarball naming behavior +5/-2

Correct 'resolved_pkg_name' docs for git/tarball naming behavior

• Updates the doc comment to reflect that git and remote-tarball resolvers typically read the package manifest during resolution, so the resolved package is named before peer hoisting. Clarifies 'None' is primarily for repos with no manifest name (e.g., no package.json).

pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs

@greptile-apps

greptile-apps Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

The 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

@qodo-code-review

qodo-code-review Bot commented Jul 26, 2026 •

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📜 Skill insights (0)

Context used
✅ Compliance rules (platform): 24 rules

Grey Divider


Remediation recommended

1. Historical phrasing in test comment ✓ Resolved 📘 Rule violation ⚙ Maintainability ⭐ New
Description
The new doc comment includes historical phrasing (Reported as broken in ...) rather than
describing the current behavior/contract. This makes the comment more about history than the
invariant the test is asserting, which can rot over time and mislead future reviewers.
Code

pnpm/crates/cli/tests/git_hosted_install.rs[R604-608]

+/// A git specifier names a repository, not a package, so the name the
+/// peer is matched on lives only in the repo's own manifest — read
+/// during resolution, early enough for the hoist that
+/// `resolvePeersFromWorkspaceRoot` runs. Reported as broken in
+/// `pnpm/pnpm#13351`.
Relevance

⭐⭐ Medium

Repo has mixed history: some reviews accept removing historical phrasing, others reject similar
requests in test comments.

PR-#13138
PR-#13234
PR-#13359

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
PR Compliance ID 772199 forbids comments that describe history rather than current behavior. The
added comment at git_hosted_install.rs[604-608] ends with Reported as broken in pnpm/pnpm#13351,
which is explicitly historical phrasing.

Rule 772199: Comments must describe current behavior, not historical implementations
pnpm/crates/cli/tests/git_hosted_install.rs[604-608]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
A newly added comment uses historical phrasing (`Reported as broken in ...`) rather than describing current behavior/invariants.

## Issue Context
Inline comments should document what the code/test currently guarantees. If an issue reference is useful, keep it but phrase it as context (e.g., “Covers scenario from ...”) instead of a historical claim.

## Fix Focus Areas
- pnpm/crates/cli/tests/git_hosted_install.rs[604-608]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Overstated naming invariant ✓ Resolved 🐞 Bug ⚙ Maintainability
Description
The updated resolved_pkg_name doc comment says git and remote-tarball resolutions "arrive named"
and that None happens only for repos without package.json, but both resolvers explicitly support
a no-fetch-context mode where manifest stays unset, and resolved_pkg_name also returns None
when manifest.name is missing/non-string. This is misleading documentation in a security-sensitive
area (attacker-controlled manifests) and can cause future changes to rely on an invariant that is
not guaranteed.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[R768-773]

/// `name_ver`, else the manifest — the canonical name for the protocols
-/// that leave `name_ver` unset. `None` for a git resolution, which has
-/// neither until it is fetched.
+/// that leave `name_ver` unset. The git and remote-tarball resolvers read
+/// the package's own manifest during resolution, so those arrive named
+/// too. `None` only for a package with no manifest name at all — a
+/// repository without a `package.json` — where the alias is the only
+/// name anywhere in the graph.
Relevance

⭐⭐⭐ High

Team often accepts doc-comment clarifications to avoid misleading invariants and improve
correctness/security rationale.

PR-#13384
PR-#13343
PR-#13172

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
resolved_pkg_name() falls back to result.manifest["name"] and returns None if manifest is
None or lacks a string name. Both GitResolver and TarballResolver explicitly document/implement
an optional fetch context; when it is None, they keep a manifest-less resolve result,
contradicting the comment’s absolute wording.

pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[768-779]
pnpm/crates/resolving-git-resolver/src/git_resolver.rs[68-72]
pnpm/crates/resolving-git-resolver/src/git_resolver.rs[128-133]
pnpm/crates/resolving-tarball-resolver/src/tarball_resolver.rs[54-60]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The doc comment for `resolved_pkg_name()` is written as if git and remote-tarball results are always named during resolution and that `None` only occurs for repos without a `package.json`. In reality, both git and remote-tarball resolvers can run without a fetch context (leaving `manifest` unset), and `resolved_pkg_name()` also returns `None` when `manifest["name"]` is absent or not a string.

### Issue Context
This PR intends to correct documentation around name availability for git dependencies. The current wording is still stronger than what the code guarantees.

### Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[768-779]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Previous review results

Review updated until commit f5a0b62

Results up to commit 44d9c3a ⚖️ Balanced


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. Overstated naming invariant ✓ Resolved 🐞 Bug ⚙ Maintainability
Description
The updated resolved_pkg_name doc comment says git and remote-tarball resolutions "arrive named"
and that None happens only for repos without package.json, but both resolvers explicitly support
a no-fetch-context mode where manifest stays unset, and resolved_pkg_name also returns None
when manifest.name is missing/non-string. This is misleading documentation in a security-sensitive
area (attacker-controlled manifests) and can cause future changes to rely on an invariant that is
not guaranteed.
Code

pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[R768-773]

/// `name_ver`, else the manifest — the canonical name for the protocols
-/// that leave `name_ver` unset. `None` for a git resolution, which has
-/// neither until it is fetched.
+/// that leave `name_ver` unset. The git and remote-tarball resolvers read
+/// the package's own manifest during resolution, so those arrive named
+/// too. `None` only for a package with no manifest name at all — a
+/// repository without a `package.json` — where the alias is the only
+/// name anywhere in the graph.
Relevance

⭐⭐⭐ High

Team often accepts doc-comment clarifications to avoid misleading invariants and improve
correctness/security rationale.

PR-#13384
PR-#13343
PR-#13172

ⓘ Recommendations generated based on similar findings in past PRs

Evidence
resolved_pkg_name() falls back to result.manifest["name"] and returns None if manifest is
None or lacks a string name. Both GitResolver and TarballResolver explicitly document/implement
an optional fetch context; when it is None, they keep a manifest-less resolve result,
contradicting the comment’s absolute wording.

pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[768-779]
pnpm/crates/resolving-git-resolver/src/git_resolver.rs[68-72]
pnpm/crates/resolving-git-resolver/src/git_resolver.rs[128-133]
pnpm/crates/resolving-tarball-resolver/src/tarball_resolver.rs[54-60]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The doc comment for `resolved_pkg_name()` is written as if git and remote-tarball results are always named during resolution and that `None` only occurs for repos without a `package.json`. In reality, both git and remote-tarball resolvers can run without a fetch context (leaving `manifest` unset), and `resolved_pkg_name()` also returns `None` when `manifest["name"]` is absent or not a string.

### Issue Context
This PR intends to correct documentation around name availability for git dependencies. The current wording is still stronger than what the code guarantees.

### Fix Focus Areas
- pnpm/crates/resolving-deps-resolver/src/resolve_importer.rs[768-779]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Qodo Logo

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@github-actions

github-actions Bot commented Jul 26, 2026 •

Copy link
Copy Markdown
Contributor

Micro-Benchmark Results

Linux

group                          main                                   pr
-----                          ----                                   --
lockfile/parse_pnpm_lock       1.00     11.2±0.09ms    33.3 MB/sec    1.01     11.3±0.04ms    33.1 MB/sec
packument/parse                1.00     36.7±0.16µs  1809.4 MB/sec    1.06     38.9±0.08µs  1705.1 MB/sec
tarball/download_dependency    1.00      2.3±0.07ms  1881.8 KB/sec    1.05      2.4±0.05ms  1799.6 KB/sec

…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]>
Copilot AI review requested due to automatic review settings July 26, 2026 00:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@zkochan

zkochan commented Jul 26, 2026

Copy link
Copy Markdown
Member Author

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 package.json when they hold a fetch context, and resolve.rs (the resolve-only NAPI entry point) deliberately wires none. The claim now carries its condition, and names the context-less chain alongside the no-package.json repository as the cases that yield None:

/// `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 resolvePeersFromWorkspaceRoot lives in.

Greptile — test comment duplicates behavior. Agreed; replied on the thread. The scenario restatement is gone, the why stays.

cargo clippy --all-targets -- --deny warnings clean, git_hosted_install 16/16 green.


Written by an agent (Claude Code, claude-opus-5).

@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit 2a5a854

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 760b2ec and 2a5a854.

📒 Files selected for processing (2)
  • pnpm/crates/cli/tests/git_hosted_install.rs
  • pnpm/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]>
Copilot AI review requested due to automatic review settings July 26, 2026 00:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the reviewed: coderabbit CodeRabbit submitted an approving review label Jul 26, 2026
@qodo-code-review

Copy link
Copy Markdown

Code review by qodo was updated up to the latest commit f5a0b62

@qodo-code-review

Copy link
Copy Markdown

PR Code Suggestions ✨

Warning

/improve is deprecated. Use /agentic_review instead (removal date not yet scheduled).

No code suggestions found for the PR.

@zkochan
zkochan merged commit 8313d31 into main Jul 26, 2026
34 of 35 checks passed
@zkochan
zkochan deleted the fix-13351 branch July 26, 2026 00:59
kairosci added a commit to kairosci/pnpm that referenced this pull request Jul 27, 2026
… 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

product: pacquet reviewed: coderabbit CodeRabbit submitted an approving review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

An aliased git workspace-root dependency can't satisfy a peer by its real package name

2 participants