Skip to content

fix: discover pnpm 11 isolated global package roots - #207

Open
Mohith26 wants to merge 2 commits into
TanStack:mainfrom
Mohith26:fix/global-pnpm-skill-discovery
Open

fix: discover pnpm 11 isolated global package roots#207
Mohith26 wants to merge 2 commits into
TanStack:mainfrom
Mohith26:fix/global-pnpm-skill-discovery

Conversation

@Mohith26

@Mohith26 Mohith26 commented Jul 29, 2026

Copy link
Copy Markdown

Fixes #206, reported by @KATT.

list --global / --global-only found nothing for packages installed globally with pnpm 11, while local scanning worked (packageJsonReadCount: 0 in debug). pnpm 11's global layout is isolated: pnpm root -g entries are symlinks into a .pnpm virtual store, and each package's dependencies live in additional roots inside that store rather than one flat node_modules, so single-root scanning reads nothing.

The fix teaches global discovery to resolve pnpm's isolated layout: symlinked roots are followed and the store's package roots are included as additional scan roots, while npm/yarn flat layouts keep working unchanged.

Nine new tests cover multi-root global discovery with temp-dir fixtures mimicking pnpm 11's layout plus the npm flat layout (no dependency on a real global install). 12 tests fail without the fix; full suite has zero new failures vs main (the 31 pre-existing env-dependent failures on main are byte-identical before and after).

Summary by CodeRabbit

  • New Features

    • Improved discovery of globally installed packages across multiple node_modules locations.
    • Added support for delimiter-separated global module paths through configuration.
    • Added compatibility with pnpm’s isolated global installation layouts.
    • Duplicate global paths are now handled without repeated scanning.
  • Bug Fixes

    • Improved detection and parsing of global module directories across package managers.
  • Tests

    • Added coverage for multiple global paths, malformed configuration, pnpm layouts, and duplicate directories.

Mohith26 added 2 commits July 28, 2026 21:34
pnpm 11 installs each global package into its own isolated directory
(<global>/<dir>/node_modules/<pkg>), so `pnpm root -g` no longer points
at a scannable node_modules dir and `list --global` came back empty.

Global detection now asks pnpm for resolved package paths via
`pnpm ls -g --json --depth 0` and derives the set of node_modules roots
(deduped; collapses to the single root on pnpm <= 10), keeping
`pnpm root -g` plus the npm/yarn commands as fallbacks. The scanner
scans every detected root, and INTENT_GLOBAL_NODE_MODULES accepts a
path.delimiter-separated list of roots.

Fixes TanStack#206
Scanner tests exercise temp-dir fixtures for the pnpm 11 isolated
global layout (several roots via a path-list override, deduped when
two roots alias the same directory) and the npm-style single global
root. Unit tests cover parsePnpmGlobalLsRoots fixture output for the
pnpm 11 and pnpm 10 layouts plus the INTENT_GLOBAL_NODE_MODULES
path-list parsing.
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Global node_modules detection now supports multiple roots, parses pnpm global package paths, accepts delimiter-separated environment overrides, and scans every configured root with integration coverage for pnpm, npm-style, and aliased layouts.

Changes

Global node_modules discovery

Layer / File(s) Summary
Global path detection and contracts
packages/intent/src/shared/types.ts, packages/intent/src/shared/utils.ts, packages/intent/tests/global-node-modules.test.ts
Global scan targets support path arrays; utilities split environment overrides, parse pnpm global metadata, return multiple roots, and test malformed, empty, and multi-root inputs.
Global scanner path wiring
packages/intent/src/discovery/scanner.ts
Scanner initialization and fallback detection populate global path arrays and associated detection, existence, and source fields.
Multi-root scanning and integration validation
packages/intent/src/discovery/register.ts, packages/intent/tests/scanner.test.ts
Global scanning iterates configured roots, with tests covering isolated pnpm roots, a single global root, and aliased roots that deduplicate discovered packages.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant scanForIntents
  participant nodeModules.global
  participant scanTarget
  participant scanNodeModulesDir
  scanForIntents->>nodeModules.global: provide global paths
  nodeModules.global->>scanTarget: expose scan target
  scanTarget->>scanNodeModulesDir: scan each configured path
  scanNodeModulesDir-->>scanForIntents: return discovered global packages
Loading

Suggested reviewers: ladybluenotes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly names the main change: discovering pnpm 11 isolated global package roots.
Description check ✅ Passed It explains the fix, motivation, and test coverage, though it does not follow the repo's template headings.
Linked Issues check ✅ Passed The code addresses #206 by scanning multiple global roots, parsing pnpm ls output, and supporting delimiter-separated env overrides.
Out of Scope Changes check ✅ Passed The changes stay focused on global node_modules discovery and related tests, with no obvious unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@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.

🧹 Nitpick comments (1)
packages/intent/tests/global-node-modules.test.ts (1)

138-148: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover automatic pnpm discovery.

This test sets the override, so it never exercises pnpm ls -g --json --depth 0. Add a mocked command/shim test for parsed roots and fallback behavior.

🤖 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 `@packages/intent/tests/global-node-modules.test.ts` around lines 138 - 148,
Add coverage for the automatic pnpm discovery path in detectGlobalNodeModules by
removing the INTENT_GLOBAL_NODE_MODULES override for that test and mocking the
pnpm ls -g --json --depth 0 command or shim. Assert parsed global module roots
and add a case verifying the existing fallback behavior when the command fails
or returns unusable output.
🤖 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 `@packages/intent/tests/global-node-modules.test.ts`:
- Around line 138-148: Add coverage for the automatic pnpm discovery path in
detectGlobalNodeModules by removing the INTENT_GLOBAL_NODE_MODULES override for
that test and mocking the pnpm ls -g --json --depth 0 command or shim. Assert
parsed global module roots and add a case verifying the existing fallback
behavior when the command fails or returns unusable output.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 16610cb9-e320-4162-a4c5-4bb96c6dd2c6

📥 Commits

Reviewing files that changed from the base of the PR and between 3e8f4af and 5fd0ce3.

📒 Files selected for processing (6)
  • packages/intent/src/discovery/register.ts
  • packages/intent/src/discovery/scanner.ts
  • packages/intent/src/shared/types.ts
  • packages/intent/src/shared/utils.ts
  • packages/intent/tests/global-node-modules.test.ts
  • packages/intent/tests/scanner.test.ts

@LadyBluenotes

Copy link
Copy Markdown
Member

Please refrain from removing the PR template when submitting a PR. It is there for a reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

list --global finds nothing when packages are installed globally with pnpm 11

2 participants