Skip to content

Commit

Permalink
fix: only the add command should fail if there is no bin directory in…
Browse files Browse the repository at this point in the history
… PATH

ref #5841
  • Loading branch information
zkochan committed Dec 27, 2022
1 parent b3dfa3b commit 2703c9f
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
7 changes: 7 additions & 0 deletions .changeset/spicy-panthers-agree.md
@@ -0,0 +1,7 @@
---
"@pnpm/config": patch
"@pnpm/plugin-commands-installation": patch
"pnpm": patch
---

Only the `pnpm add --global <pkg>` command should fail if there is no global pnpm bin directory in the system PATH [#5841](https://github.com/pnpm/pnpm/issues/5841).
4 changes: 0 additions & 4 deletions config/config/src/index.ts
Expand Up @@ -316,10 +316,6 @@ export async function getConfig (
if (pnpmConfig.bin) {
fs.mkdirSync(pnpmConfig.bin, { recursive: true })
await checkGlobalBinDir(pnpmConfig.bin, { env, shouldAllowWrite: opts.globalDirShouldAllowWrite })
} else {
throw new PnpmError('NO_GLOBAL_BIN_DIR', 'Unable to find the global bin directory', {
hint: 'Run "pnpm setup" to create it automatically, or set the global-bin-dir setting, or the PNPM_HOME env variable. The global bin directory should be in the PATH.',
})
}
pnpmConfig.save = true
pnpmConfig.allowNew = true
Expand Down
5 changes: 5 additions & 0 deletions pkg-manager/plugin-commands-installation/src/add.ts
Expand Up @@ -193,6 +193,11 @@ export async function handler (
'If you don\'t want to see this warning anymore, you may set the ignore-workspace-root-check setting to true.'
)
}
if (opts.global && !opts.bin) {
throw new PnpmError('NO_GLOBAL_BIN_DIR', 'Unable to find the global bin directory', {
hint: 'Run "pnpm setup" to create it automatically, or set the global-bin-dir setting, or the PNPM_HOME env variable. The global bin directory should be in the PATH.',
})
}

const include = {
dependencies: opts.production !== false,
Expand Down

0 comments on commit 2703c9f

Please sign in to comment.