Skip to content

fix(config): restore globalconfig lookup#12252

Merged
zkochan merged 2 commits into
pnpm:mainfrom
marko1olo:fix-config-get-globalconfig
Jun 7, 2026
Merged

fix(config): restore globalconfig lookup#12252
zkochan merged 2 commits into
pnpm:mainfrom
marko1olo:fix-config-get-globalconfig

Conversation

@marko1olo

@marko1olo marko1olo commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • restore pnpm config get globalconfig to return the current global config.yaml path
  • keep npm-globalconfig unsupported
  • add unit and CLI e2e coverage for the v11 global config location

Fixes #11962.

Tests

  • node --input-type=module -e "..." direct regression check before fix: printed undefined
  • .\node_modules\.bin\tsgo.cmd --build config\commands
  • ..\..\node_modules\.bin\jest.cmd configGet.test.ts --runInBand
  • .\node_modules\.bin\eslint.cmd config\commands\src\configGet.ts config\commands\test\configGet.test.ts pnpm\test\config\get.ts
  • .\node_modules\.bin\tsgo.cmd --build pnpm
  • node bundle.ts with package env vars
  • ..\node_modules\.bin\jest.cmd test/config/get.ts --runInBand --config ..\__utils__\jest-config\config.js --rootDir .
  • pre-push hook: TypeScript build, spellcheck, meta-updater, and lint passed; the hook reported cargo and taplo unavailable, so Rust/TOML checks were skipped by the hook.

Written by an agent (OpenAI Codex, GPT-5).

Summary by CodeRabbit

  • Bug Fixes

    • pnpm config get globalconfig now correctly returns the path to the global config.yaml file.
  • Tests

    • Added and updated tests to ensure the globalconfig path is accurate and that values written to that file are read by pnpm, improving reliability of global config lookup.

@marko1olo marko1olo requested a review from zkochan as a code owner June 7, 2026 01:52
@welcome

welcome Bot commented Jun 7, 2026

Copy link
Copy Markdown

💖 Thanks for opening this pull request! 💖
Please be patient and we will get back to you as soon as we can.

@coderabbitai

coderabbitai Bot commented Jun 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 079bb0b2-a5ed-46fa-b536-9e476b53a729

📥 Commits

Reviewing files that changed from the base of the PR and between b0dbfd4 and b751a22.

📒 Files selected for processing (6)
  • .changeset/fix-config-globalconfig.md
  • config/commands/src/configGet.ts
  • config/commands/test/configGet.test.ts
  • config/reader/src/dirs.ts
  • config/reader/src/index.ts
  • pnpm/test/config/get.ts
💤 Files with no reviewable changes (1)
  • config/commands/test/configGet.test.ts
✅ Files skipped from review due to trivial changes (1)
  • .changeset/fix-config-globalconfig.md
📜 Recent review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Compile & Lint
  • GitHub Check: Analyze (javascript)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: Use Standard Style with trailing commas, prefer functions over classes, declare functions after they are used (relying on hoisting), limit functions to no more than two or three arguments, and use a single options object for functions needing more parameters
Follow import order: standard libraries first, then external dependencies (sorted alphabetically), then relative imports
Do not write comments that restate what the code already says; rename variables, split helpers, or move checks to more obvious places instead
Do not repeat documentation at call sites that already lives on the callee; update the JSDoc once and let every call site benefit
Use JSDoc for the function's contract (preconditions, postconditions, edge cases, why the function exists), not for re-narrating the function body
Do not record past implementation shape, refactor history, or removed code in comments; use git log and git blame for that information instead
Write comments only when the reason for code is non-obvious, a hidden invariant exists, a workaround for a known bug is needed, or an exception to surrounding pattern is deliberate

Files:

  • config/reader/src/dirs.ts
  • config/commands/src/configGet.ts
  • pnpm/test/config/get.ts
  • config/reader/src/index.ts
🧠 Learnings (15)
📓 Common learnings
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11904
File: pacquet/crates/package-manager/src/install.rs:556-560
Timestamp: 2026-05-24T16:07:54.784Z
Learning: In pacquet's `is_modules_yaml_consistent` (pacquet/crates/package-manager/src/install.rs), `enableGlobalVirtualStore` is intentionally NOT checked as a separate field. Upstream pnpm's `validateModules.ts` does not persist or check `enableGlobalVirtualStore` in `.modules.yaml` either. Drift on this setting is caught indirectly: toggling `enableGlobalVirtualStore` changes `config.effective_virtual_store_dir()` (GVS-on → `<store>/v11/links`, GVS-off → `<project>/node_modules/.pnpm`), so the existing `modules.virtual_store_dir == config.effective_virtual_store_dir()` comparison in `is_modules_yaml_consistent` already detects the mismatch and prevents the short-circuit. Do not flag the absence of an explicit `enableGlobalVirtualStore` field as a bug.
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: pacquet/AGENTS.md:0-0
Timestamp: 2026-05-29T18:03:15.372Z
Learning: Match how the same feature is implemented in the TypeScript pnpm CLI — any change in pacquet must match pnpm's behavior, logic, edge cases, config resolution, error messages, file/lockfile formats, and existing tests
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-06-06T22:48:27.363Z
Learning: Keep pnpm and pacquet in sync — any user-visible change (CLI flags, defaults, environment-variable handling, lockfile/manifest/state-file format, error codes and messages, log emissions, store layout, hook semantics) must land in both the TypeScript pnpm CLI and the Rust pacquet port in the same PR
📚 Learning: 2026-05-14T09:04:00.133Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11622
File: resolving/npm-resolver/test/publishedBy.test.ts:350-354
Timestamp: 2026-05-14T09:04:00.133Z
Learning: In the pnpm/pnpm repository, ESLint is the authoritative style linter. Do not raise review findings for missing trailing commas in multiline function calls (e.g., `fs.writeFileSync(...)`) when this repo’s ESLint configuration does not report them and lint passes. Prefer deferring to the ESLint results for this specific trailing-comma rule rather than enforcing it manually in code review.

Applied to files:

  • config/reader/src/dirs.ts
  • config/commands/src/configGet.ts
  • pnpm/test/config/get.ts
  • config/reader/src/index.ts
📚 Learning: 2026-06-05T13:47:26.046Z
Learnt from: vsumner
Repo: pnpm/pnpm PR: 12190
File: installing/deps-installer/src/install/index.ts:2337-2343
Timestamp: 2026-06-05T13:47:26.046Z
Learning: In the pnpm/pnpm codebase, `PnpmError` automatically prefixes `err.code` with `ERR_PNPM_` when you pass a code that does not already start with `ERR_PNPM_` (it normalizes `this.code` via `code.startsWith('ERR_PNPM_') ? code : `ERR_PNPM_${code}``). Therefore, during code review you should NOT flag `new PnpmError(...)` call sites for passing a bare error code (e.g., `new PnpmError('FROZEN_STORE_INCOMPATIBLE_WITH_PNPR', ...)`); the resulting `err.code` will still be `ERR_PNPM_FROZEN_STORE_INCOMPATIBLE_WITH_PNPR`.

Applied to files:

  • config/reader/src/dirs.ts
  • config/commands/src/configGet.ts
  • pnpm/test/config/get.ts
  • config/reader/src/index.ts
📚 Learning: 2026-05-15T11:37:17.491Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11526
File: config/reader/src/loadNpmrcFiles.ts:189-195
Timestamp: 2026-05-15T11:37:17.491Z
Learning: In pnpm/pnpm `config/reader/src/loadNpmrcFiles.ts`, the `resolveEnvValue` helper intentionally diverges from `pnpm/config.env-replace`'s strict path (which uses `hasOwnProperty`) by checking `env[varName] === undefined` instead. This is deliberate: the strict path only sees `process.env` (which never holds `undefined` values), whereas `resolveEnvValue` is also called from tests that model an unset variable as `{ KEY: undefined }`. Using `=== undefined` ensures that `${VAR-default}` falls back to `default` when the variable is present but set to `undefined`, consistent with the `Record<string, string | undefined>` public API contract.

Applied to files:

  • config/commands/src/configGet.ts
  • pnpm/test/config/get.ts
  • config/reader/src/index.ts
📚 Learning: 2026-05-11T16:10:11.551Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11588
File: global/commands/src/globalAdd.ts:64-67
Timestamp: 2026-05-11T16:10:11.551Z
Learning: In `global/commands/src/globalAdd.ts` (pnpm repo), the sequential per-group install loop in `handleGlobalAdd` is intentional: each space-separated CLI param is an independent install, semantically equivalent to running `pnpm add -g` once per arg. Partial success across groups is by design. A two-phase commit across groups is explicitly rejected because the bin-conflict check for group N depends on groups 1..N-1 already being symlinked — deferring symlinks would break incremental conflict detection. Users who want atomicity across multiple packages opt in via comma syntax (e.g. `pnpm add -g foo,bar`), which installs them as a single group with all-or-nothing behavior.

Applied to files:

  • config/commands/src/configGet.ts
📚 Learning: 2026-05-29T18:03:15.372Z
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: pacquet/AGENTS.md:0-0
Timestamp: 2026-05-29T18:03:15.372Z
Learning: Match how the same feature is implemented in the TypeScript pnpm CLI — any change in pacquet must match pnpm's behavior, logic, edge cases, config resolution, error messages, file/lockfile formats, and existing tests

Applied to files:

  • config/commands/src/configGet.ts
  • pnpm/test/config/get.ts
  • config/reader/src/index.ts
📚 Learning: 2026-05-24T08:18:00.622Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11895
File: pnpm/test/deploy.ts:91-95
Timestamp: 2026-05-24T08:18:00.622Z
Learning: In pnpm/pnpm integration tests that intentionally hit the real npm registry (registry.npmjs.org)—for example when the test passes `--config.registry=https://registry.npmjs.org/` to `execPnpm` and simply increases the timeout—do not request adding a runtime environment-variable gate (e.g., `PNPM_RUN_PUBLIC_REGISTRY_TESTS`). This is the established pattern for those tests (see files like `pnpm/test/install/pacquet.ts` and `pnpm/test/deploy.ts`).

Applied to files:

  • pnpm/test/config/get.ts
📚 Learning: 2026-06-05T13:47:05.929Z
Learnt from: vsumner
Repo: pnpm/pnpm PR: 12190
File: installing/deps-installer/test/install/frozenStore.ts:2-17
Timestamp: 2026-06-05T13:47:05.929Z
Learning: In the pnpm/pnpm repository, the shared Jest preset keeps `injectGlobals` at its default (`true`), so `test` and `expect` are available as Jest globals. Therefore, reviewers should not flag (or treat as TypeScript/compilation errors) missing `import { test, expect } from 'jest/globals'` when a test file uses `test`/`expect` without importing them. Importing from `jest/globals` may still be used for consistency with sibling files, but it is not required for execution in this repo unless a Jest preset is explicitly configured with `injectGlobals: false`.

Applied to files:

  • pnpm/test/config/get.ts
📚 Learning: 2026-05-24T16:07:54.784Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11904
File: pacquet/crates/package-manager/src/install.rs:556-560
Timestamp: 2026-05-24T16:07:54.784Z
Learning: In pacquet's `is_modules_yaml_consistent` (pacquet/crates/package-manager/src/install.rs), `enableGlobalVirtualStore` is intentionally NOT checked as a separate field. Upstream pnpm's `validateModules.ts` does not persist or check `enableGlobalVirtualStore` in `.modules.yaml` either. Drift on this setting is caught indirectly: toggling `enableGlobalVirtualStore` changes `config.effective_virtual_store_dir()` (GVS-on → `<store>/v11/links`, GVS-off → `<project>/node_modules/.pnpm`), so the existing `modules.virtual_store_dir == config.effective_virtual_store_dir()` comparison in `is_modules_yaml_consistent` already detects the mismatch and prevents the short-circuit. Do not flag the absence of an explicit `enableGlobalVirtualStore` field as a bug.

Applied to files:

  • pnpm/test/config/get.ts
  • config/reader/src/index.ts
📚 Learning: 2026-05-20T21:18:56.391Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11778
File: pacquet/crates/resolving-local-resolver/tests/resolve.rs:365-372
Timestamp: 2026-05-20T21:18:56.391Z
Learning: In `pacquet/crates/resolving-local-resolver/tests/resolve.rs`, the test `fail_when_resolving_from_not_existing_directory_an_injected_dependency` intentionally uses `injected: false`. The test is a verbatim port of the upstream pnpm TypeScript test (resolving/local-resolver/test/index.ts at ef87f3ccff). The `injected` flag only affects the file/link protocol choice for plain directory paths; when the `file:` scheme is explicit in the bare specifier, the flag has no effect on the resolution code path. The misleading test name is inherited from upstream.

Applied to files:

  • pnpm/test/config/get.ts
📚 Learning: 2026-06-06T22:48:27.363Z
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-06-06T22:48:27.363Z
Learning: Keep pnpm and pacquet in sync — any user-visible change (CLI flags, defaults, environment-variable handling, lockfile/manifest/state-file format, error codes and messages, log emissions, store layout, hook semantics) must land in both the TypeScript pnpm CLI and the Rust pacquet port in the same PR

Applied to files:

  • pnpm/test/config/get.ts
  • config/reader/src/index.ts
📚 Learning: 2026-05-19T19:23:00.981Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11752
File: pacquet/crates/config/src/lib.rs:1062-1073
Timestamp: 2026-05-19T19:23:00.981Z
Learning: In `pacquet/crates/config/src/lib.rs`, `modules_dir` does not need a `!virtual_store_dir_explicit` guard on its workspace re-anchor because `modules_dir` is in pnpm's `excludedPnpmKeys` (filtered out by `WorkspaceSettings::clear_workspace_only_fields`) and therefore can only be set by workspace yaml (applied immediately after) or env vars (applied later in the cascade) — not by global `config.yaml`. `virtual_store_dir`, by contrast, IS settable from global config and requires the `if !virtual_store_dir_explicit` guard to survive the workspace-root re-anchor.

Applied to files:

  • pnpm/test/config/get.ts
  • config/reader/src/index.ts
📚 Learning: 2026-05-29T18:03:15.372Z
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: pacquet/AGENTS.md:0-0
Timestamp: 2026-05-29T18:03:15.372Z
Learning: Applies to pacquet/**/tests/**/*.rs : Port relevant pnpm tests to Rust tests whenever they translate when porting behavior from pnpm

Applied to files:

  • pnpm/test/config/get.ts
📚 Learning: 2026-05-05T23:03:30.044Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11479
File: __utils__/scripts/package.json:6-9
Timestamp: 2026-05-05T23:03:30.044Z
Learning: In the pnpm/pnpm repository, the pattern `cross-env NODE_OPTIONS="$NODE_OPTIONS ..." jest` is an intentional, established convention used across many package.json files (e.g., `fs/hard-link-dir`, `worker`, `__utils__/scripts`). Do not flag this as a cross-platform issue in individual files; any fix should be applied repo-wide as a separate change.

Applied to files:

  • pnpm/test/config/get.ts
📚 Learning: 2026-06-06T22:48:27.363Z
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-06-06T22:48:27.363Z
Learning: After changing any package, rebuild the bundle with `pnpm --filter pnpm run compile` (which runs tsgo --build, linting, and pnpm run bundle) before running e2e tests, as pnpm CLI e2e tests use the bundled pnpm/dist/pnpm.mjs

Applied to files:

  • pnpm/test/config/get.ts
🔇 Additional comments (9)
config/reader/src/dirs.ts (2)

4-5: LGTM!


6-8: LGTM!

config/reader/src/index.ts (3)

39-39: LGTM!


55-55: LGTM!


309-309: LGTM!

config/commands/src/configGet.ts (2)

1-1: LGTM!


38-40: LGTM!

pnpm/test/config/get.ts (2)

279-279: LGTM!


294-307: LGTM!


📝 Walkthrough

Walkthrough

Recognize the special key globalconfig in config lookup and return the computed global config YAML path via a new helper; update config reader to use the helper; add unit and integration tests and a changeset documenting the fix.

Changes

Restore globalconfig key support

Layer / File(s) Summary
Path helper and reader wiring
config/reader/src/dirs.ts, config/reader/src/index.ts
Add getGlobalConfigPath(configDir) (uses GLOBAL_CONFIG_YAML_FILENAME) and rewire getConfig to call it for the global config path.
Command: recognize globalconfig key
config/commands/src/configGet.ts
Import getGlobalConfigPath and make lookupConfig return { value: getGlobalConfigPath(opts.configDir) } when key === 'globalconfig'.
Tests and changeset
config/commands/test/configGet.test.ts, pnpm/test/config/get.ts, .changeset/fix-config-globalconfig.md
Add unit test asserting config get globalconfig returns <configDir>/config.yaml, add integration test that writes to the returned path and verifies subsequent reads, and update the changeset to document the fix and target patch releases.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • pnpm/pnpm#11494: Modifies config/commands/src/configGet.ts key-resolution logic at the same decision point in lookupConfig.

Suggested reviewers

  • zkochan

Poem

🐰 A nibble at code in the night,
I hopped through paths until things were right.
globalconfig now shows its way,
Config.yaml saved—hip hooray!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(config): restore globalconfig lookup' directly and accurately summarizes the main change - restoring the globalconfig key functionality.
Linked Issues check ✅ Passed Changes fully address issue #11962 by implementing globalconfig lookup in configGet, adding getGlobalConfigPath helper, and including e2e tests verifying the functionality.
Out of Scope Changes check ✅ Passed All changes are directly related to restoring globalconfig lookup functionality and adding necessary test coverage; no unrelated modifications detected.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


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 and usage tips.

@qodo-free-for-open-source-projects

Copy link
Copy Markdown

Review Summary by Qodo

Restore globalconfig lookup in pnpm config get

🐞 Bug fix

Grey Divider

Walkthroughs

Description
• Restore pnpm config get globalconfig to return global config.yaml path
• Add unit test coverage for globalconfig lookup functionality
• Add CLI e2e test for v11 global config location
• Keep npm-globalconfig unsupported as intended
Diagram
flowchart LR
  A["configGet.ts"] -->|"add globalconfig handler"| B["Returns config.yaml path"]
  C["configGet.test.ts"] -->|"add unit test"| B
  D["get.ts e2e test"] -->|"add CLI test"| B
  E["changeset"] -->|"document fix"| F["pnpm/pnpm#11962"]

Loading

Grey Divider

File Changes

1. config/commands/src/configGet.ts 🐞 Bug fix +6/-0

Add globalconfig key handler to config lookup

• Import path module and GLOBAL_CONFIG_YAML_FILENAME constant
• Add special case handler for globalconfig key that returns path to global config.yaml
• Constructs path by joining opts.configDir with the global config filename

config/commands/src/configGet.ts


2. config/commands/test/configGet.test.ts 🧪 Tests +16/-1

Add unit test for globalconfig lookup

• Import path module for path operations
• Add new unit test for config get globalconfig command
• Test verifies globalconfig returns correct path to global config.yaml
• Update comment to clarify only npm-globalconfig is removed

config/commands/test/configGet.test.ts


3. pnpm/test/config/get.ts 🧪 Tests +1/-0

Add e2e test for globalconfig command

• Add e2e test assertion for globalconfig command
• Verify globalconfig returns path to config.yaml in global config directory
• Test runs within existing global config test suite

pnpm/test/config/get.ts


View more (1)
4. .changeset/fix-config-globalconfig.md 📝 Documentation +6/-0

Document globalconfig fix in changeset

• Create changeset documenting the bug fix
• Mark patches for @pnpm/config.commands and pnpm packages
• Reference issue pnpm/pnpm#11962

.changeset/fix-config-globalconfig.md


Grey Divider

Qodo Logo

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
config/commands/test/configGet.test.ts (1)

285-285: ⚡ Quick win

Remove history/removal commentary from test source.

This comment documents removed tests rather than current behavior; please drop it (or keep that note in PR/changeset text instead).

As per coding guidelines, “Do not record past implementation shape, refactor history, or removed code in comments; use git log and git blame for that information instead.”

🤖 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 `@config/commands/test/configGet.test.ts` at line 285, Remove the obsolete
explanatory comment "// npm-globalconfig tests removed — pnpm no longer exposes
these npm-compat properties" from the test source in configGet.test.ts; this is
recording past removal rather than current behavior — simply delete that comment
line (or move the note into the PR/changeset) so the test file only contains
current, relevant comments and assertions.

Source: Coding guidelines

🤖 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 `@config/commands/test/configGet.test.ts`:
- Line 285: Remove the obsolete explanatory comment "// npm-globalconfig tests
removed — pnpm no longer exposes these npm-compat properties" from the test
source in configGet.test.ts; this is recording past removal rather than current
behavior — simply delete that comment line (or move the note into the
PR/changeset) so the test file only contains current, relevant comments and
assertions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e92c5142-fb7b-4ae5-a747-b001806b25cd

📥 Commits

Reviewing files that changed from the base of the PR and between 75bf4bf and b0dbfd4.

📒 Files selected for processing (4)
  • .changeset/fix-config-globalconfig.md
  • config/commands/src/configGet.ts
  • config/commands/test/configGet.test.ts
  • pnpm/test/config/get.ts
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Compile & Lint
  • GitHub Check: Analyze (javascript)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (AGENTS.md)

**/*.{ts,tsx,js,jsx}: Use Standard Style with trailing commas, prefer functions over classes, declare functions after they are used (relying on hoisting), limit functions to no more than two or three arguments, and use a single options object for functions needing more parameters
Follow import order: standard libraries first, then external dependencies (sorted alphabetically), then relative imports
Do not write comments that restate what the code already says; rename variables, split helpers, or move checks to more obvious places instead
Do not repeat documentation at call sites that already lives on the callee; update the JSDoc once and let every call site benefit
Use JSDoc for the function's contract (preconditions, postconditions, edge cases, why the function exists), not for re-narrating the function body
Do not record past implementation shape, refactor history, or removed code in comments; use git log and git blame for that information instead
Write comments only when the reason for code is non-obvious, a hidden invariant exists, a workaround for a known bug is needed, or an exception to surrounding pattern is deliberate

Files:

  • config/commands/src/configGet.ts
  • pnpm/test/config/get.ts
  • config/commands/test/configGet.test.ts
**/*.test.{ts,tsx}

📄 CodeRabbit inference engine (AGENTS.md)

Do not use instanceof Error for checking if a caught error is an Error object in Jest tests; use util.types.isNativeError() instead to work across realms

Files:

  • config/commands/test/configGet.test.ts
🧠 Learnings (21)
📓 Common learnings
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11904
File: pacquet/crates/package-manager/src/install.rs:556-560
Timestamp: 2026-05-24T16:07:54.784Z
Learning: In pacquet's `is_modules_yaml_consistent` (pacquet/crates/package-manager/src/install.rs), `enableGlobalVirtualStore` is intentionally NOT checked as a separate field. Upstream pnpm's `validateModules.ts` does not persist or check `enableGlobalVirtualStore` in `.modules.yaml` either. Drift on this setting is caught indirectly: toggling `enableGlobalVirtualStore` changes `config.effective_virtual_store_dir()` (GVS-on → `<store>/v11/links`, GVS-off → `<project>/node_modules/.pnpm`), so the existing `modules.virtual_store_dir == config.effective_virtual_store_dir()` comparison in `is_modules_yaml_consistent` already detects the mismatch and prevents the short-circuit. Do not flag the absence of an explicit `enableGlobalVirtualStore` field as a bug.
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: pacquet/AGENTS.md:0-0
Timestamp: 2026-05-29T18:03:15.372Z
Learning: Match how the same feature is implemented in the TypeScript pnpm CLI — any change in pacquet must match pnpm's behavior, logic, edge cases, config resolution, error messages, file/lockfile formats, and existing tests
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-06-06T22:48:27.363Z
Learning: Keep pnpm and pacquet in sync — any user-visible change (CLI flags, defaults, environment-variable handling, lockfile/manifest/state-file format, error codes and messages, log emissions, store layout, hook semantics) must land in both the TypeScript pnpm CLI and the Rust pacquet port in the same PR
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11526
File: config/reader/src/loadNpmrcFiles.ts:189-195
Timestamp: 2026-05-15T11:37:17.491Z
Learning: In pnpm/pnpm `config/reader/src/loadNpmrcFiles.ts`, the `resolveEnvValue` helper intentionally diverges from `pnpm/config.env-replace`'s strict path (which uses `hasOwnProperty`) by checking `env[varName] === undefined` instead. This is deliberate: the strict path only sees `process.env` (which never holds `undefined` values), whereas `resolveEnvValue` is also called from tests that model an unset variable as `{ KEY: undefined }`. Using `=== undefined` ensures that `${VAR-default}` falls back to `default` when the variable is present but set to `undefined`, consistent with the `Record<string, string | undefined>` public API contract.
Learnt from: vsumner
Repo: pnpm/pnpm PR: 12190
File: installing/deps-installer/test/install/frozenStore.ts:2-17
Timestamp: 2026-06-05T13:47:05.929Z
Learning: In the `pnpm/pnpm` repository, the shared Jest preset does NOT set `injectGlobals: false` (it defaults to `true`), so `test` and `expect` are available as globals without an explicit import. Adding `import { expect, test } from 'jest/globals'` is a convention-consistency practice to match sibling test files — it is not required for compilation or test execution. Do not flag missing `jest/globals` imports as compile errors in this repo.
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11895
File: pnpm/test/deploy.ts:91-95
Timestamp: 2026-05-24T08:18:06.019Z
Learning: In the pnpm/pnpm repository, integration tests that hit the real `registry.npmjs.org` (e.g., for `pacquet` or `pnpm/pacquet`) do NOT use a runtime env-var gate (such as `PNPM_RUN_PUBLIC_REGISTRY_TESTS`). They simply pass `--config.registry=https://registry.npmjs.org/` directly to `execPnpm` and set a higher timeout. This is the established pattern, as seen in `pnpm/test/install/pacquet.ts` and `pnpm/test/deploy.ts`. Do not suggest adding env-var guards for these tests.
📚 Learning: 2026-05-15T11:37:17.491Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11526
File: config/reader/src/loadNpmrcFiles.ts:189-195
Timestamp: 2026-05-15T11:37:17.491Z
Learning: In pnpm/pnpm `config/reader/src/loadNpmrcFiles.ts`, the `resolveEnvValue` helper intentionally diverges from `pnpm/config.env-replace`'s strict path (which uses `hasOwnProperty`) by checking `env[varName] === undefined` instead. This is deliberate: the strict path only sees `process.env` (which never holds `undefined` values), whereas `resolveEnvValue` is also called from tests that model an unset variable as `{ KEY: undefined }`. Using `=== undefined` ensures that `${VAR-default}` falls back to `default` when the variable is present but set to `undefined`, consistent with the `Record<string, string | undefined>` public API contract.

Applied to files:

  • config/commands/src/configGet.ts
  • pnpm/test/config/get.ts
  • config/commands/test/configGet.test.ts
📚 Learning: 2026-05-14T09:04:00.133Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11622
File: resolving/npm-resolver/test/publishedBy.test.ts:350-354
Timestamp: 2026-05-14T09:04:00.133Z
Learning: In the pnpm/pnpm repository, ESLint is the authoritative style linter. Do not raise review findings for missing trailing commas in multiline function calls (e.g., `fs.writeFileSync(...)`) when this repo’s ESLint configuration does not report them and lint passes. Prefer deferring to the ESLint results for this specific trailing-comma rule rather than enforcing it manually in code review.

Applied to files:

  • config/commands/src/configGet.ts
  • pnpm/test/config/get.ts
  • config/commands/test/configGet.test.ts
📚 Learning: 2026-06-05T13:47:26.046Z
Learnt from: vsumner
Repo: pnpm/pnpm PR: 12190
File: installing/deps-installer/src/install/index.ts:2337-2343
Timestamp: 2026-06-05T13:47:26.046Z
Learning: In the pnpm/pnpm codebase, `PnpmError` automatically prefixes `err.code` with `ERR_PNPM_` when you pass a code that does not already start with `ERR_PNPM_` (it normalizes `this.code` via `code.startsWith('ERR_PNPM_') ? code : `ERR_PNPM_${code}``). Therefore, during code review you should NOT flag `new PnpmError(...)` call sites for passing a bare error code (e.g., `new PnpmError('FROZEN_STORE_INCOMPATIBLE_WITH_PNPR', ...)`); the resulting `err.code` will still be `ERR_PNPM_FROZEN_STORE_INCOMPATIBLE_WITH_PNPR`.

Applied to files:

  • config/commands/src/configGet.ts
  • pnpm/test/config/get.ts
  • config/commands/test/configGet.test.ts
📚 Learning: 2026-05-29T18:03:15.372Z
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: pacquet/AGENTS.md:0-0
Timestamp: 2026-05-29T18:03:15.372Z
Learning: Match how the same feature is implemented in the TypeScript pnpm CLI — any change in pacquet must match pnpm's behavior, logic, edge cases, config resolution, error messages, file/lockfile formats, and existing tests

Applied to files:

  • pnpm/test/config/get.ts
  • .changeset/fix-config-globalconfig.md
  • config/commands/test/configGet.test.ts
📚 Learning: 2026-06-05T13:47:05.929Z
Learnt from: vsumner
Repo: pnpm/pnpm PR: 12190
File: installing/deps-installer/test/install/frozenStore.ts:2-17
Timestamp: 2026-06-05T13:47:05.929Z
Learning: In the pnpm/pnpm repository, the shared Jest preset keeps `injectGlobals` at its default (`true`), so `test` and `expect` are available as Jest globals. Therefore, reviewers should not flag (or treat as TypeScript/compilation errors) missing `import { test, expect } from 'jest/globals'` when a test file uses `test`/`expect` without importing them. Importing from `jest/globals` may still be used for consistency with sibling files, but it is not required for execution in this repo unless a Jest preset is explicitly configured with `injectGlobals: false`.

Applied to files:

  • pnpm/test/config/get.ts
  • config/commands/test/configGet.test.ts
📚 Learning: 2026-05-24T16:07:54.784Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11904
File: pacquet/crates/package-manager/src/install.rs:556-560
Timestamp: 2026-05-24T16:07:54.784Z
Learning: In pacquet's `is_modules_yaml_consistent` (pacquet/crates/package-manager/src/install.rs), `enableGlobalVirtualStore` is intentionally NOT checked as a separate field. Upstream pnpm's `validateModules.ts` does not persist or check `enableGlobalVirtualStore` in `.modules.yaml` either. Drift on this setting is caught indirectly: toggling `enableGlobalVirtualStore` changes `config.effective_virtual_store_dir()` (GVS-on → `<store>/v11/links`, GVS-off → `<project>/node_modules/.pnpm`), so the existing `modules.virtual_store_dir == config.effective_virtual_store_dir()` comparison in `is_modules_yaml_consistent` already detects the mismatch and prevents the short-circuit. Do not flag the absence of an explicit `enableGlobalVirtualStore` field as a bug.

Applied to files:

  • pnpm/test/config/get.ts
  • .changeset/fix-config-globalconfig.md
📚 Learning: 2026-05-20T21:18:56.391Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11778
File: pacquet/crates/resolving-local-resolver/tests/resolve.rs:365-372
Timestamp: 2026-05-20T21:18:56.391Z
Learning: In `pacquet/crates/resolving-local-resolver/tests/resolve.rs`, the test `fail_when_resolving_from_not_existing_directory_an_injected_dependency` intentionally uses `injected: false`. The test is a verbatim port of the upstream pnpm TypeScript test (resolving/local-resolver/test/index.ts at ef87f3ccff). The `injected` flag only affects the file/link protocol choice for plain directory paths; when the `file:` scheme is explicit in the bare specifier, the flag has no effect on the resolution code path. The misleading test name is inherited from upstream.

Applied to files:

  • pnpm/test/config/get.ts
  • config/commands/test/configGet.test.ts
📚 Learning: 2026-05-24T08:18:00.622Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11895
File: pnpm/test/deploy.ts:91-95
Timestamp: 2026-05-24T08:18:00.622Z
Learning: In pnpm/pnpm integration tests that intentionally hit the real npm registry (registry.npmjs.org)—for example when the test passes `--config.registry=https://registry.npmjs.org/` to `execPnpm` and simply increases the timeout—do not request adding a runtime environment-variable gate (e.g., `PNPM_RUN_PUBLIC_REGISTRY_TESTS`). This is the established pattern for those tests (see files like `pnpm/test/install/pacquet.ts` and `pnpm/test/deploy.ts`).

Applied to files:

  • pnpm/test/config/get.ts
📚 Learning: 2026-06-06T22:48:27.363Z
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-06-06T22:48:27.363Z
Learning: Keep pnpm and pacquet in sync — any user-visible change (CLI flags, defaults, environment-variable handling, lockfile/manifest/state-file format, error codes and messages, log emissions, store layout, hook semantics) must land in both the TypeScript pnpm CLI and the Rust pacquet port in the same PR

Applied to files:

  • pnpm/test/config/get.ts
  • .changeset/fix-config-globalconfig.md
📚 Learning: 2026-06-06T22:48:27.363Z
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-06-06T22:48:27.363Z
Learning: Always explicitly include `pnpm` in changesets with the appropriate version bump; the pnpm CLI only receives automatic patch bumps from dependencies, so minor or major bumps must be specified explicitly

Applied to files:

  • .changeset/fix-config-globalconfig.md
📚 Learning: 2026-06-06T22:48:27.363Z
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-06-06T22:48:27.363Z
Learning: Create a changeset file in the `.changeset` directory for changes that affect published packages, specifying affected packages and version bump types (patch, minor, major)

Applied to files:

  • .changeset/fix-config-globalconfig.md
📚 Learning: 2026-05-20T23:08:06.093Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11784
File: pacquet/crates/resolving-deps-resolver/src/hoist_peers.rs:120-133
Timestamp: 2026-05-20T23:08:06.093Z
Learning: Pacquet (pnpm's Rust port) has a cardinal rule: "match pnpm exactly — do not fix pnpm quirks unless the same fix has landed in pnpm first." Review comments should not suggest behavioral deviations from upstream pnpm, even when the upstream behavior appears buggy. If a real bug is identified, it must be fixed upstream first.

Applied to files:

  • .changeset/fix-config-globalconfig.md
📚 Learning: 2026-05-11T16:10:11.551Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11588
File: global/commands/src/globalAdd.ts:64-67
Timestamp: 2026-05-11T16:10:11.551Z
Learning: In `global/commands/src/globalAdd.ts` (pnpm repo), the sequential per-group install loop in `handleGlobalAdd` is intentional: each space-separated CLI param is an independent install, semantically equivalent to running `pnpm add -g` once per arg. Partial success across groups is by design. A two-phase commit across groups is explicitly rejected because the bin-conflict check for group N depends on groups 1..N-1 already being symlinked — deferring symlinks would break incremental conflict detection. Users who want atomicity across multiple packages opt in via comma syntax (e.g. `pnpm add -g foo,bar`), which installs them as a single group with all-or-nothing behavior.

Applied to files:

  • .changeset/fix-config-globalconfig.md
📚 Learning: 2026-05-29T18:03:15.372Z
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: pacquet/AGENTS.md:0-0
Timestamp: 2026-05-29T18:03:15.372Z
Learning: Do not change lockfile format, store layout, `.npmrc` semantics, or CLI surface unless pnpm changed them first

Applied to files:

  • .changeset/fix-config-globalconfig.md
📚 Learning: 2026-05-26T21:01:06.666Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11966
File: .changeset/require-tarball-integrity.md:6-6
Timestamp: 2026-05-26T21:01:06.666Z
Learning: In pnpm lockfile-related release notes/docs (especially changeset markdown), preserve URL hostnames exactly as they appear in pnpm-lock.yaml tarball resolution entries—keep hosts like `codeload.github.com`, `bitbucket.org`, and `gitlab.com` in lowercase. Do not “correct” them to title-case/preserve brand capitalization (e.g., LanguageTool rules like `GITHUB` capitalization) because these are literal URL fragments, not platform brand names.

Applied to files:

  • .changeset/fix-config-globalconfig.md
📚 Learning: 2026-05-05T23:03:30.044Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11479
File: __utils__/scripts/package.json:6-9
Timestamp: 2026-05-05T23:03:30.044Z
Learning: In the pnpm/pnpm repository, the pattern `cross-env NODE_OPTIONS="$NODE_OPTIONS ..." jest` is an intentional, established convention used across many package.json files (e.g., `fs/hard-link-dir`, `worker`, `__utils__/scripts`). Do not flag this as a cross-platform issue in individual files; any fix should be applied repo-wide as a separate change.

Applied to files:

  • config/commands/test/configGet.test.ts
📚 Learning: 2026-05-24T08:18:06.019Z
Learnt from: zkochan
Repo: pnpm/pnpm PR: 11895
File: pnpm/test/deploy.ts:91-95
Timestamp: 2026-05-24T08:18:06.019Z
Learning: In the pnpm/pnpm repository, integration tests that hit the real `registry.npmjs.org` (e.g., for `pacquet` or `pnpm/pacquet`) do NOT use a runtime env-var gate (such as `PNPM_RUN_PUBLIC_REGISTRY_TESTS`). They simply pass `--config.registry=https://registry.npmjs.org/` directly to `execPnpm` and set a higher timeout. This is the established pattern, as seen in `pnpm/test/install/pacquet.ts` and `pnpm/test/deploy.ts`. Do not suggest adding env-var guards for these tests.

Applied to files:

  • config/commands/test/configGet.test.ts
📚 Learning: 2026-06-06T22:48:27.363Z
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: AGENTS.md:0-0
Timestamp: 2026-06-06T22:48:27.363Z
Learning: Do not run all tests in the repository; run tests for a specific project instead using `pnpm test`, `pnpm --filter <package_name> test`, or `pnpm --filter <package_name> test <file_path>`

Applied to files:

  • config/commands/test/configGet.test.ts
📚 Learning: 2026-05-29T18:03:15.372Z
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: pacquet/AGENTS.md:0-0
Timestamp: 2026-05-29T18:03:15.372Z
Learning: Applies to pacquet/**/tests/**/*.rs : Port relevant pnpm tests to Rust tests whenever they translate when porting behavior from pnpm

Applied to files:

  • config/commands/test/configGet.test.ts
📚 Learning: 2026-05-29T18:03:15.372Z
Learnt from: CR
Repo: pnpm/pnpm PR: 0
File: pacquet/AGENTS.md:0-0
Timestamp: 2026-05-29T18:03:15.372Z
Learning: Applies to pacquet/**/*.rs : Tests are documentation — do not duplicate test scenarios, edge cases, failure modes, or worked examples in prose when they are already captured by tests

Applied to files:

  • config/commands/test/configGet.test.ts

Extract getGlobalConfigPath into @pnpm/config.reader and use it for both
the reader's warning message and 'config get globalconfig' so the reported
path cannot drift from the file pnpm actually reads. Add an e2e test that
writes a setting to the reported path and reads it back.
@zkochan zkochan merged commit 6b5d91a into pnpm:main Jun 7, 2026
10 checks passed
@welcome

welcome Bot commented Jun 7, 2026

Copy link
Copy Markdown

Congrats on merging your first pull request! 🎉🎉🎉

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.

pnpm config get globalconfig returns undefined on v11

2 participants