From a575dd24615bf2b82df277f10b6d24afbe450857 Mon Sep 17 00:00:00 2001 From: Zoltan Kochan Date: Mon, 11 May 2026 19:53:44 +0200 Subject: [PATCH] fix: allow `pnpm runtime set` in workspace root (#11584) * fix: allow `pnpm runtime set` in workspace root `pnpm runtime set ` 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. --- .changeset/runtime-set-workspace-root.md | 6 ++++++ engine/runtime/commands/src/runtime/runtime.ts | 2 ++ engine/runtime/commands/test/runtime.test.ts | 2 +- 3 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 .changeset/runtime-set-workspace-root.md diff --git a/.changeset/runtime-set-workspace-root.md b/.changeset/runtime-set-workspace-root.md new file mode 100644 index 0000000000..c066dc0cd2 --- /dev/null +++ b/.changeset/runtime-set-workspace-root.md @@ -0,0 +1,6 @@ +--- +"@pnpm/engine.runtime.commands": patch +"pnpm": patch +--- + +`pnpm runtime set ` 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. diff --git a/engine/runtime/commands/src/runtime/runtime.ts b/engine/runtime/commands/src/runtime/runtime.ts index 9c769a7a20..49ac563434 100644 --- a/engine/runtime/commands/src/runtime/runtime.ts +++ b/engine/runtime/commands/src/runtime/runtime.ts @@ -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) diff --git a/engine/runtime/commands/test/runtime.test.ts b/engine/runtime/commands/test/runtime.test.ts index dcf6be67e3..685e47ab61 100644 --- a/engine/runtime/commands/test/runtime.test.ts +++ b/engine/runtime/commands/test/runtime.test.ts @@ -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' } ) })