mirror of
https://github.com/pnpm/pnpm.git
synced 2026-06-09 08:54:57 -04:00
fix: allow pnpm runtime set in workspace root (#11584)
* fix: allow `pnpm runtime set` in workspace root `pnpm runtime set <name> <version>` previously failed in the root of a multi-package workspace with the `ADDING_TO_ROOT` error. Since installing a runtime is workspace-wide configuration, pass `--workspace-root` to the underlying `pnpm add` call when not running globally. * fix: use --ignore-workspace-root-check instead of --workspace-root The previous fix forced every non-global runtime install to land in the workspace root, which broke running the command from a workspace subproject. Switch to --ignore-workspace-root-check, which only suppresses the safety warning and leaves the install target as the current directory.
This commit is contained in:
6
.changeset/runtime-set-workspace-root.md
Normal file
6
.changeset/runtime-set-workspace-root.md
Normal file
@@ -0,0 +1,6 @@
|
||||
---
|
||||
"@pnpm/engine.runtime.commands": patch
|
||||
"pnpm": patch
|
||||
---
|
||||
|
||||
`pnpm runtime set <name> <version>` no longer fails in the root of a multi-package workspace with the `ADDING_TO_ROOT` error. Installing the workspace root is a valid target for a runtime, so the command now bypasses that safety check.
|
||||
@@ -94,6 +94,8 @@ function runtimeSet (opts: RuntimeCommandOptions, params: string[]): void {
|
||||
if (opts.global) {
|
||||
args.push('--global')
|
||||
if (opts.bin) args.push('--global-bin-dir', opts.bin)
|
||||
} else {
|
||||
args.push('--ignore-workspace-root-check')
|
||||
}
|
||||
if (opts.storeDir) args.push('--store-dir', opts.storeDir)
|
||||
if (opts.cacheDir) args.push('--cache-dir', opts.cacheDir)
|
||||
|
||||
@@ -37,7 +37,7 @@ test('runtime set uses project dir when not global', async () => {
|
||||
}, ['set', 'node', '22'])
|
||||
|
||||
expect(mockRunPnpmCli).toHaveBeenCalledWith(
|
||||
['add', 'node@runtime:22'],
|
||||
['add', 'node@runtime:22', '--ignore-workspace-root-check'],
|
||||
{ cwd: '/tmp/project' }
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user