Skip to content

fix: store global binaries in PNPM_HOME/bin subdirectory#11038

Merged
zkochan merged 7 commits into
mainfrom
fix/10986
Mar 20, 2026
Merged

fix: store global binaries in PNPM_HOME/bin subdirectory#11038
zkochan merged 7 commits into
mainfrom
fix/10986

Conversation

@zkochan

@zkochan zkochan commented Mar 20, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #10986

  • Global binaries are now stored in PNPM_HOME/bin instead of directly in PNPM_HOME
  • pnpm setup now adds PNPM_HOME/bin to PATH instead of PNPM_HOME
  • pnpm self-update links bins to the bin subdirectory
  • Added a hint to the GLOBAL_BIN_DIR_NOT_IN_PATH error suggesting pnpm setup

This prevents internal directories like global/ and store/ from appearing in shell autocompletion when PNPM_HOME is on PATH.

Note: After upgrading, users need to run pnpm setup to update their shell configuration. The GLOBAL_BIN_DIR_NOT_IN_PATH error now includes a hint about this.

Note: pnpm setup no longer sets the PNPM_HOME environment variable in shell config (it only adds the bin dir to PATH). pnpm determines its data directory via getDataDir() which uses platform-specific defaults.

Test plan

  • Config reader tests pass (7 previously failing global tests now pass)
  • Setup tests pass
  • Compilation succeeds
  • Linting passes
  • Manual test: pnpm setup adds <data-dir>/bin to PATH
  • Manual test: pnpm add -g <pkg> places binaries in <data-dir>/bin
  • Verify pnpm self-update links to the bin subdirectory

🤖 Generated with Claude Code

Related PR:

zkochan and others added 3 commits March 20, 2026 13:53
Previously, globally installed binaries were placed directly in
PNPM_HOME, which also contains internal directories (global/, store/).
This polluted shell autocompletion with non-executable entries.

Now binaries are stored in PNPM_HOME/bin, keeping the PATH clean.

Closes #10986

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Once @pnpm/os.env.path-extender supports proxyVarSubDir, setup should
use it to properly set PNPM_HOME and add $PNPM_HOME/bin to PATH.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Update setup to use proxyVarSubDir: 'bin' so shell config generates:
  export PNPM_HOME="/path/to/pnpm"
  PATH="$PNPM_HOME/bin:$PATH"

This properly sets PNPM_HOME while keeping only the bin subdir on PATH.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@zkochan zkochan marked this pull request as ready for review March 20, 2026 14:36
Copilot AI review requested due to automatic review settings March 20, 2026 14:36

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.

Pull request overview

This PR adjusts pnpm’s global binary layout so that globally installed executables live under PNPM_HOME/bin (instead of directly in PNPM_HOME), and updates related commands/config to match—reducing PATH/autocomplete “pollution” from internal directories.

Changes:

  • Change the global bin directory default to <data-dir>/bin and update PATH/setup behavior accordingly.
  • Update pnpm setup and pnpm self-update to link/use the new bin subdirectory.
  • Improve the GLOBAL_BIN_DIR_NOT_IN_PATH error by adding a pnpm setup hint, and bump @pnpm/os.env.path-extender to v3.

Reviewed changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
pnpm-workspace.yaml Bumps @pnpm/os.env.path-extender catalog version to support new setup behavior.
pnpm-lock.yaml Lockfile updates for the @pnpm/os.env.path-extender@3 upgrade.
engine/runtime/commands/src/env/utils.ts Updates node exec path helper to use the bin/ subdirectory.
engine/pm/commands/src/setup/setup.ts Makes pnpm setup add <PNPM_HOME>/bin to PATH and writes pnpx shims into bin/.
engine/pm/commands/src/self-updater/selfUpdate.ts Links self-updated pnpm binaries into <PNPM_HOME>/bin.
config/reader/test/index.ts Adjusts config reader tests to expect PATH to include <PNPM_HOME>/bin.
config/reader/src/index.ts Changes global default config.bin fallback to <data-dir>/bin.
config/reader/src/checkGlobalBinDir.ts Adds a hint suggesting pnpm setup when the global bin dir isn’t in PATH.
.changeset/fix-global-bin-subdir.md Documents the behavior change and instructs users to rerun pnpm setup.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread config/reader/src/index.ts
Comment thread config/reader/src/checkGlobalBinDir.ts Outdated
zkochan and others added 4 commits March 20, 2026 16:02
Tests now add pnpmHomeDir/bin to PATH instead of pnpmHomeDir,
matching the new bin directory layout.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The prepareOptions helper and the "without package.json" test
now set bin to pnpmHomeDir/bin to match the new layout.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Derive pnpmHomeDir from the passed env instead of process.env, so
  pnpmHomeDir and bin are always consistent (even in tests/embedded usage)
- Fix misleading error message: "pnpm home directory" → "global bin directory"

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- global.ts: PATH now includes pnpmHome/bin, bin existence checks
  use pnpmHome/bin/ prefix
- uninstall.ts: PNPM_HOME points to parent dir, not the bin dir
- root.ts: PATH includes pnpmHome/bin
- bin.ts: PATH and expected output use pnpmHome/bin

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

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.

Pull request overview

Copilot reviewed 13 out of 14 changed files in this pull request and generated no new comments.

Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@zkochan zkochan added this to the v11.0 milestone Mar 20, 2026
@zkochan zkochan merged commit f0ae1b9 into main Mar 20, 2026
16 checks passed
@zkochan zkochan deleted the fix/10986 branch March 20, 2026 17:16
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.

Redundant artifacts in PATH for global binaries

2 participants