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' } ) })