fix: handle CRLF line endings in extractMainLockfileDocument - #35840
Closed
godfengliang wants to merge 1 commit into
Closed
fix: handle CRLF line endings in extractMainLockfileDocument#35840godfengliang wants to merge 1 commit into
godfengliang wants to merge 1 commit into
Conversation
On Windows, pnpm lockfile content may have CRLF ( ) line endings, but extractMainLockfileDocument uses LF-only strings ( --- ) to find YAML document separators. This causes the function to fail on Windows. Normalize line endings to LF at the start of the function. Fixes nrwl#35828
👷 Deploy request for nx-docs pending review.Visit the deploys page to approve it
|
👷 Deploy request for nx-dev pending review.Visit the deploys page to approve it
|
FrozenPandaz
requested changes
Jun 2, 2026
FrozenPandaz
left a comment
Contributor
There was a problem hiding this comment.
You'll need to recommit this with the escape sequences /r/n and /n. Otherwise, this does not compile.
pvds
reviewed
Jun 22, 2026
| @@ -69,6 +69,12 @@ const YAML_DOCUMENT_SEPARATOR = '\n---\n'; | |||
| // always read the workspace document. | |||
| // https://github.com/pnpm/pnpm/blob/main/lockfile/fs/src/yamlDocuments.ts | |||
Contributor
There was a problem hiding this comment.
Remote url has been updated:
Suggested change
| // https://github.com/pnpm/pnpm/blob/main/lockfile/fs/src/yamlDocuments.ts | |
| // https://github.com/pnpm/pnpm/blob/main/pnpm11/lockfile/fs/src/yamlDocuments.ts |
pvds
reviewed
Jun 22, 2026
Comment on lines
+75
to
+77
| content = content.replace(/ | ||
| /g, ' | ||
| '); |
Contributor
There was a problem hiding this comment.
As per pnpm lockfile example
Suggested change
| content = content.replace(/ | |
| /g, ' | |
| '); | |
| content = content.replace(/\r\n/g, '\n') |
FrozenPandaz
added a commit
that referenced
this pull request
Jul 29, 2026
…36419) ## Current Behavior `extractMainLockfileDocument` matches the pnpm multi-document markers with LF-only strings (`'---\n'` and `'\n---\n'`). When `pnpm-lock.yaml` is written with CRLF line endings (common on Windows), the markers never match: `startsWith('---\n')` is false, so the raw two-document content flows into YAML parsing and project-graph construction fails with `expected a single document in the stream, but found more`. ## Expected Behavior Line endings are normalized to LF before the document markers are matched, so multi-document lockfiles written with CRLF are split correctly and the workspace lock document is parsed on Windows. A CRLF variant of the multi-document lockfile test pins the behavior. ## Related Issue(s) Fixes #35828 Closes #35840 <!-- polygraph-session-start --> --- [View session information ↗](https://app.trypolygraph.com/orgs/6a061dcb561c062131116eca/sessions/Fix-CRLF-pnpm-lockfile-parsing-on-Windows-0e926b99) <!-- polygraph-session-end --> --------- Co-authored-by: nx-cloud[bot] <71083854+nx-cloud[bot]@users.noreply.github.com> (cherry picked from commit b8dca5e)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On Windows, pnpm lockfile content may have CRLF line endings, but uses LF-only strings to find YAML document separators. This causes to fail on Windows.
Fix
Normalize line endings to LF at the start of .
Fixes #35828