Skip to content

pnpm exec/dlx forces the pinned version on all child processes #14309

Description

@sacrosanctic

Verify latest release

  • I verified that the issue exists in the latest pnpm release

pnpm version

11.24

Which area(s) of pnpm are affected? (leave empty if unsure)

CLI

Link to the code that reproduces this issue or a replay of the bug

No response

Reproduction steps

mkdir -p repro/a repro/b && cd repro
printf '{"packageManager":"pnpm@10.15.0"}' > a/package.json
printf '{"packageManager":"pnpm@9.15.0"}'  > b/package.json

echo "global:      $(pnpm --version)"                                  # 11.24.0
cd a
echo "in a:        $(pnpm --version)"                                  # 10.15.0 (intended switch)
echo "child in b:  $(pnpm exec sh -c 'cd ../b && pnpm --version')"     # 10.15.0, expected 9.15.0
echo "child out:   $(pnpm exec sh -c 'cd .. && pnpm --version')"       # 10.15.0, expected 11.24.0

Describe the Bug

When pnpm auto-switches to the packageManager-pinned version, it prepends the pinned binary to PATH and sets npm_config_manage_package_manager_versions=false for all descendants. Any tool launched via pnpm exec/dlx and every pnpm it spawns is then permanently locked to the launcher's pinned version: it can neither honor the pin of the directory it actually operates in, nor discover the user's global pnpm.

Expected Behavior

The version lock should be scoped to the directory that triggered the switch. A child pnpm run elsewhere should re-evaluate packageManager for its own directory (falling back to the user's global when unpinned). At minimum, the originally invoked version should be discoverable.

Which Node.js version are you using?

22.20.0

Which operating systems have you used?

  • macOS
  • Windows
  • Linux

If your OS is a Linux based, which one it is? (Include the version if relevant)

No response

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions