Skip to content

Runtime version detection breaks when pnpm writes [WARN] to stdout #57

Description

@igas

What happens

Every job using pnpm/setup@v2.1.0 with a runtime to install gets a warning annotation:

Unable to determine the installed runtime versions: Unexpected token 'W', "[WARN] Usin"... is not valid JSON

The runtime itself installs fine — only the version refinement (and the cache key it feeds) falls back.

Why

getInstalledRuntimeVersions (src/install-runtime/index.ts) does:

const stdout = await runPnpmForOutput(binDest, ['list', '--global', '--json', '--depth', '0'])
const listing = JSON.parse(stdout)

pnpm 12 writes a warning to stdout, ahead of the JSON, when the project configures pmOnFail:

[WARN] Using --global skips the package manager check for this project

so JSON.parse sees [WARN] Usin....

Repro (pnpm 12.4.1)

mkdir repro && cd repro
printf '{"name":"t","version":"1.0.0"}' > package.json
printf 'pmOnFail: warn\n' > pnpm-workspace.yaml   # `error` does it too; removing the key does not
pnpm list --global --json --depth 0 | head -1
# [WARN] Using --global skips the package manager check for this project

Suggested fix

pnpm list --reporter=silent --global --json --depth 0 returns clean JSON in the same repro. Alternatively, slice from the first [ before parsing, so any future stdout noise is tolerated — the comment above the function already says this path must never break setup.

Happy to send a PR if you'd like.

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

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions