Skip to content

Fix pnpm 12 lockfile parsing ("Multiple documents are not supported") - #75

Open
maks-oleksyuk wants to merge 1 commit into
laravel:1.xfrom
maks-oleksyuk:pr/pnpm12-multi-document-lockfile
Open

maks-oleksyuk wants to merge 1 commit into
laravel:1.xfrom
maks-oleksyuk:pr/pnpm12-multi-document-lockfile

Conversation

@maks-oleksyuk

Copy link
Copy Markdown

pnpm 12 (e.g. "packageManager": "pnpm@12.17.0") writes pnpm-lock.yaml as two YAML documents: the first one pins pnpm itself (packageManagerDependencies), the second one is the regular project lockfile.

---
lockfileVersion: '9.0'
importers:
  .:
    configDependencies: {}
    packageManagerDependencies:
      pnpm: { specifier: 12.17.0, version: 12.17.0 }
---
lockfileVersion: '9.0'
settings: ...
importers: ...
packages: ...

PnpmPackageLock passes the whole file to Yaml::parse(). Symfony YAML does not support multi-document files by design, so it throws Multiple documents are not supported at line N (near "---"). Roster then logs Failed to parse pnpm-lock.yaml and marks the scanner as failed, so no JS packages are detected for pnpm 12 projects (e.g. Boost no longer sees package versions).

Fix

Split the contents on document separators (/^---\s*$/m), drop empty chunks and parse the last document, which is the project lockfile.

Why it doesn't break anything

  • Single-document lockfiles (pnpm 5–11) produce a single chunk and are parsed exactly as before.
  • An empty file still ends up in the existing "Malformed pnpm-lock.yaml" branch.
  • pnpm itself (from the first document) is not reported as a project package.

Tests

Added a pnpm 12 fixture with two documents: the scanner no longer fails, prettier is detected as a dev dependency, and pnpm is not listed. The test fails without the fix.

Verified on a real pnpm 12.17.0 project: 0 → 78 packages detected, all 6 root devDependencies classified correctly.

Unrelated

composer test failed on rector --dry-run on 1.x with the current Rector 2.8 (NegatedAndsToPositiveOrsRector in BunPackageLock). Applied the equivalent condition rewrite (!(a && !b) → !a || b) so the full suite passes. Happy to drop it if you'd rather keep this PR focused.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@maks-oleksyuk
maks-oleksyuk force-pushed the pr/pnpm12-multi-document-lockfile branch from ecc719c to c4ad313 Compare November 3, 2026 14:46
@maks-oleksyuk

Copy link
Copy Markdown
Author

Failed CI runs do not affect the changes that have been made

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant