Repository navigation
Conversation
`extract_main_document` / `extract_env_document` split the combined `pnpm-lock.yaml` on literal `---\n` and `\n---\n`. A lockfile pacquet did not write may carry CRLF line endings — a `core.autocrlf` checkout on Windows — or a UTF-8 BOM, and neither marker then matches. The main extractor fell through to returning the whole file, which serde rejected as `multiple YAML documents detected`, so the lockfile was discarded and every dependency re-resolved from the registry. Normalize the whole file (strip BOM, CRLF to LF) inside both extractors, which covers every caller. `save_value_to_path` already normalized the same way inline and now shares the helper. The TypeScript stack needs no counterpart change: `pnpm11/lockfile/fs/src/yamlDocuments.ts` already normalizes CRLF in `extractMainDocument` / `extractEnvDocument` and strips the BOM at each read site. Closes #13606
📝 WalkthroughWalkthroughLockfile reading now normalizes UTF-8 BOMs and CRLF line endings before extracting YAML documents. A new ChangesCRLF/BOM-safe lockfile document extraction
Estimated code review effort: 2 (Simple) | ~15 minutes Assessment against linked issues
Possibly related PRs
Suggested labels: Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
PR Summary by QodoFix CRLF/BOM handling for multi-document pnpm-lock.yaml parsing
AI Description
Diagram
High-Level Assessment
Files changed (8)
|
Confidence Score: 5/5The PR appears safe to merge; no concrete changed-code failure remains after reviewing the normalization, extraction, and read/write paths. The new normalization matches the TypeScript implementation, all Cow-returning extractor callers preserve valid ownership and document boundaries, and focused tests cover CRLF and BOM handling across extraction and loading. Reviews (1): Last reviewed commit: "fix(lockfile): read a CRLF or BOM-prefix..." | Re-trigger Greptile |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pnpm/crates/lockfile/src/save_lockfile.rs (1)
84-85: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick winPreserve the borrowed
Cowon the unchanged path.At Line 85,
.into_owned()clones every existing lockfile. This defeatsnormalize_lockfile_contentreturningCow::Borrowedwhen no BOM or CRLF is present.Keep the
Stringfromread_to_stringalive, then normalize it throughas_deref(). This allocates only when normalization changes the content.As per path instructions, use
Cow<'_, str>so unchanged content remains borrowed and normalization allocates only when required.Proposed refactor
- let existing = match fs::read_to_string(path) { - Ok(existing) => Some(normalize_lockfile_content(&existing).into_owned()), + let existing_content = match fs::read_to_string(path) { + Ok(existing) => Some(existing), Err(error) if error.kind() == io::ErrorKind::NotFound => None, Err(error) => return Err(SaveLockfileError::WriteFile(error)), }; + let existing = existing_content + .as_deref() + .map(normalize_lockfile_content);🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@pnpm/crates/lockfile/src/save_lockfile.rs` around lines 84 - 85, Update the existing lockfile branch in the read flow around normalize_lockfile_content to preserve its borrowed Cow: keep the read_to_string String alive, pass it through as_deref(), and store the normalized result as Cow<'_, str> instead of calling into_owned(). Ensure allocation occurs only when normalization changes the content.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@pnpm/crates/lockfile/src/save_lockfile.rs`:
- Around line 84-85: Update the existing lockfile branch in the read flow around
normalize_lockfile_content to preserve its borrowed Cow: keep the read_to_string
String alive, pass it through as_deref(), and store the normalized result as
Cow<'_, str> instead of calling into_owned(). Ensure allocation occurs only when
normalization changes the content.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: f4472d9c-e80a-461b-a8fa-a39e2dfa7629
📒 Files selected for processing (8)
.changeset/read-crlf-multi-document-lockfile.mdpnpm/crates/lockfile/src/env_lockfile.rspnpm/crates/lockfile/src/env_lockfile/tests.rspnpm/crates/lockfile/src/load_lockfile.rspnpm/crates/lockfile/src/load_lockfile/tests.rspnpm/crates/lockfile/src/save_lockfile.rspnpm/crates/lockfile/src/yaml_documents.rspnpm/crates/lockfile/src/yaml_documents/tests.rs
|
CI note:
These should go green once Every other job is green, including Clippy, Doc, Dylint, and the 1902 other tests in the same macos run. Written by an agent (Claude Code, claude-opus-5). |
Code Review by Qodo
Context used✅ Compliance rules (platform):
24 rules 1. Regression doccomment is historical
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Micro-Benchmark ResultsLinux |
|
Re the Qodo finding that the changeset is missing a
This fix is Rust-only — the TypeScript stack already normalizes CRLF in Qodo scored this finding Written by an agent (Claude Code, claude-opus-5). |
|
Addendum to the CI note above, for accuracy: because nextest stops scheduling after a failure, these runs aborted before reaching They were verified locally instead: Also for the record: the two Written by an agent (Claude Code, claude-opus-5). |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #13609 +/- ##
=======================================
Coverage 87.99% 88.00%
=======================================
Files 568 568
Lines 98002 98017 +15
=======================================
+ Hits 86239 86258 +19
+ Misses 11763 11759 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Integrated-Benchmark Report (Linux)Commit: Regular scenarios report direct and pnpr installs. The peer-heavy resolver scenario compares current Rust, main Rust, and TypeScript pnpm. Bencher consumes pacquet@HEAD and pnpr@HEAD. The tables below show mean ± σ; Bencher thresholds on the minimum latency, which is far less perturbed by shared-runner contention (noise only adds time). Scenario: Isolated linker: fresh restore, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.85232121486,
"stddev": 0.16018666183082364,
"median": 2.82902759656,
"user": 2.88628426,
"system": 2.20260066,
"min": 2.54295216456,
"max": 3.08357509256,
"times": [
2.75828834256,
2.83416311156,
3.00401277256,
2.78070081056,
3.08357509256,
2.96552207756,
2.98852710756,
2.7415785875600003,
2.54295216456,
2.82389208156
]
},
{
"command": "pacquet@main",
"mean": 2.9837154427600003,
"stddev": 0.3116796792709169,
"median": 2.91892508956,
"user": 3.19112786,
"system": 2.4377862599999998,
"min": 2.6851826985600002,
"max": 3.62778015656,
"times": [
2.7297691245599998,
2.72333039456,
3.15581796156,
3.14236330756,
3.62778015656,
3.03830369556,
3.23758337056,
2.6851826985600002,
2.69747723456,
2.79954648356
]
},
{
"command": "pnpr@HEAD",
"mean": 1.66681533236,
"stddev": 0.14162729126809387,
"median": 1.63101752356,
"user": 1.9908447599999999,
"system": 1.8814692599999998,
"min": 1.5235196745600001,
"max": 1.96272284156,
"times": [
1.66947683656,
1.5235196745600001,
1.55221184956,
1.96272284156,
1.5697875855599999,
1.84312219556,
1.7005656015600001,
1.69410711456,
1.59255821056,
1.5600814135599999
]
},
{
"command": "pnpr@main",
"mean": 1.7569179953599998,
"stddev": 0.18362749051213906,
"median": 1.69961637706,
"user": 2.0403138599999995,
"system": 1.9341328599999996,
"min": 1.56087783356,
"max": 2.01834508856,
"times": [
1.74731244056,
2.01834508856,
1.56087783356,
2.00725313856,
1.63096875456,
1.67235882356,
2.00360575356,
1.72687393056,
1.58640247056,
1.61518171956
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.46613138750000005,
"stddev": 0.033453812890760326,
"median": 0.46809332760000005,
"user": 0.40244805999999994,
"system": 0.75139986,
"min": 0.4014866501,
"max": 0.5063220081,
"times": [
0.46841430310000004,
0.5063220081,
0.5058143411,
0.47896139610000005,
0.49385278810000005,
0.4369299931,
0.4014866501,
0.46777235210000007,
0.46578864510000006,
0.4359713981
]
},
{
"command": "pacquet@main",
"mean": 0.4347787718,
"stddev": 0.033610967775492245,
"median": 0.4351782551,
"user": 0.36422496,
"system": 0.73668696,
"min": 0.37884541010000006,
"max": 0.49645505110000004,
"times": [
0.43402046310000003,
0.4563774031,
0.4179206521,
0.4320673031,
0.45134723210000005,
0.49645505110000004,
0.4363360471,
0.45289468110000003,
0.37884541010000006,
0.3915234751
]
},
{
"command": "pnpr@HEAD",
"mean": 0.45052554060000005,
"stddev": 0.03577722226543313,
"median": 0.44035963610000006,
"user": 0.40370945999999996,
"system": 0.7387585599999998,
"min": 0.4023532221,
"max": 0.5185256631,
"times": [
0.44150359210000006,
0.48862736110000005,
0.43477978410000007,
0.5185256631,
0.4220923481,
0.48027960510000006,
0.45770431610000006,
0.43921568010000006,
0.4023532221,
0.42017383410000003
]
},
{
"command": "pnpr@main",
"mean": 0.4834665255000001,
"stddev": 0.041324214093015864,
"median": 0.4847560221,
"user": 0.38686985999999995,
"system": 0.79003556,
"min": 0.40668235310000006,
"max": 0.5466821181,
"times": [
0.49156283310000004,
0.40668235310000006,
0.5466821181,
0.4535677631,
0.5181898981,
0.48317918210000005,
0.48633286210000004,
0.5266372191,
0.47545672010000006,
0.44637430610000006
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 3.0738259884799994,
"stddev": 0.07131121786782783,
"median": 3.0641514595799997,
"user": 2.8461119199999994,
"system": 2.19044282,
"min": 2.94418451908,
"max": 3.2092170580799997,
"times": [
3.2092170580799997,
3.0886868320799996,
3.1443805980799997,
3.0387712790799997,
3.06815723208,
3.1100927490799997,
3.03809119208,
3.03653273808,
3.06014568708,
2.94418451908
]
},
{
"command": "pacquet@main",
"mean": 3.03299623658,
"stddev": 0.08669104680305645,
"median": 3.04157607558,
"user": 2.78639212,
"system": 2.2048375199999994,
"min": 2.82599938308,
"max": 3.15816618708,
"times": [
2.82599938308,
3.02561805708,
3.02820443108,
2.98356611008,
3.15816618708,
3.08585901208,
3.0477550020799997,
3.0916420320799998,
3.04030380208,
3.04284834908
]
},
{
"command": "pnpr@HEAD",
"mean": 1.72154021648,
"stddev": 0.13020951524066138,
"median": 1.66325398658,
"user": 1.8571073199999997,
"system": 1.7927806200000003,
"min": 1.56331941708,
"max": 1.89274261208,
"times": [
1.8850855620800002,
1.6802484180800001,
1.64625955508,
1.64156689608,
1.5842096860800001,
1.8921318160800003,
1.7844990180800002,
1.6453391840800002,
1.89274261208,
1.56331941708
]
},
{
"command": "pnpr@main",
"mean": 1.7253537212800005,
"stddev": 0.17951169303494544,
"median": 1.7205057785800002,
"user": 1.6975292199999998,
"system": 1.6468926199999998,
"min": 1.50528696808,
"max": 2.0425219600799998,
"times": [
1.7473642560800002,
2.0425219600799998,
1.77763525208,
1.63220959908,
1.50528696808,
1.9193869160800001,
1.51757126308,
1.6936473010800002,
1.55609110408,
1.86182259308
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.5102759909,
"stddev": 0.041077721291245185,
"median": 0.5113407459,
"user": 0.70761754,
"system": 0.91269256,
"min": 0.42807479240000007,
"max": 0.5757400944,
"times": [
0.42807479240000007,
0.48636766840000006,
0.5133628964,
0.5334327214,
0.5084489874,
0.5256432234,
0.5093185954,
0.47387330140000006,
0.5484976284,
0.5757400944
]
},
{
"command": "pacquet@main",
"mean": 0.6227705273000002,
"stddev": 0.07059709825098072,
"median": 0.6225251884,
"user": 0.84171934,
"system": 1.01404206,
"min": 0.5170969984,
"max": 0.7249630264,
"times": [
0.5374970114000001,
0.5720053944,
0.6559183624,
0.6365992574,
0.6084511194,
0.5875732354000001,
0.5170969984,
0.7107160614,
0.6768848064,
0.7249630264
]
},
{
"command": "pnpr@HEAD",
"mean": 0.45818382729999996,
"stddev": 0.027950504857015206,
"median": 0.4577424579,
"user": 0.34891054,
"system": 0.77876956,
"min": 0.4094854264000001,
"max": 0.49581696640000006,
"times": [
0.4257529024000001,
0.44507798440000007,
0.49581696640000006,
0.44348796940000007,
0.47928589540000005,
0.4882033404000001,
0.4551490624,
0.4792428724000001,
0.46033585340000005,
0.4094854264000001
]
},
{
"command": "pnpr@main",
"mean": 0.3937930501000001,
"stddev": 0.021820737029799746,
"median": 0.3959113369,
"user": 0.26202354,
"system": 0.68214926,
"min": 0.36291833440000004,
"max": 0.44093974240000006,
"times": [
0.36291833440000004,
0.3784870464,
0.44093974240000006,
0.40379518940000003,
0.4085539074,
0.39656056940000006,
0.37603396740000006,
0.39527712840000007,
0.37881907040000007,
0.39654554540000003
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.9903030564200002,
"stddev": 0.08234971146361635,
"median": 1.9837730981200004,
"user": 1.2256924200000001,
"system": 1.1613880399999998,
"min": 1.8552946546200002,
"max": 2.16764694762,
"times": [
2.16764694762,
1.95247133262,
1.9303291096200001,
1.9474032216200001,
1.8552946546200002,
1.9737398566200002,
2.02808452362,
2.03262915162,
2.02162542662,
1.9938063396200003
]
},
{
"command": "pacquet@main",
"mean": 2.11567067462,
"stddev": 0.0924478000704011,
"median": 2.13096458112,
"user": 1.3939449199999998,
"system": 1.27494914,
"min": 1.9847514826200001,
"max": 2.21867100162,
"times": [
1.9980748956200003,
2.0389877156200003,
2.05335123662,
1.9847514826200001,
2.21867100162,
2.08906952962,
2.19730297262,
2.1950162836200002,
2.1728596326200003,
2.20862199562
]
},
{
"command": "pnpr@HEAD",
"mean": 0.44752408162,
"stddev": 0.026137372889528752,
"median": 0.44328539012,
"user": 0.32481891999999996,
"system": 0.7448264400000001,
"min": 0.41577584062,
"max": 0.49503452162,
"times": [
0.47360657862,
0.47160849062,
0.42319254262,
0.43084014762,
0.43618812462,
0.49503452162,
0.45481054162,
0.45038265562,
0.42380137262,
0.41577584062
]
},
{
"command": "pnpr@main",
"mean": 0.48356057312,
"stddev": 0.02290700936327454,
"median": 0.48995572412,
"user": 0.3593334199999999,
"system": 0.7313753399999999,
"min": 0.44598475762,
"max": 0.51221682262,
"times": [
0.44998805362,
0.51221682262,
0.46941284562,
0.49728711762,
0.49623737662,
0.50714064662,
0.44598475762,
0.47597780262,
0.48367407162000003,
0.49768623662
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.29955428426,
"stddev": 0.02846170642572156,
"median": 0.28928921116000006,
"user": 0.26060418,
"system": 0.15398142,
"min": 0.26893194516,
"max": 0.34707571716,
"times": [
0.34648913916,
0.26893194516,
0.27898632916000005,
0.27669504616,
0.28692732616000005,
0.30743684116000003,
0.27789830216000005,
0.34707571716,
0.31345110016000005,
0.29165109616
]
},
{
"command": "pacquet@main",
"mean": 0.3039401382509091,
"stddev": 0.0391356641980179,
"median": 0.31130077416,
"user": 0.2707194981818182,
"system": 0.14787184727272729,
"min": 0.25049563516000006,
"max": 0.36329910616000005,
"times": [
0.25049563516000006,
0.33603965716000006,
0.36329910616000005,
0.36126546316,
0.26729460116000003,
0.31466086516,
0.26703018016,
0.31907349316000005,
0.27505574416000006,
0.31130077416,
0.27782600116000006
]
},
{
"command": "pnpr@HEAD",
"mean": 0.11233923823999997,
"stddev": 0.008809914345541008,
"median": 0.11070076916000002,
"user": 0.035452199999999996,
"system": 0.017251799999999998,
"min": 0.09880835616000001,
"max": 0.13376229816000001,
"times": [
0.11033055416000001,
0.12245964116000002,
0.10329583216000002,
0.09880835616000001,
0.11093964416000002,
0.10517691416000001,
0.11082929816000002,
0.10085562316000002,
0.10850912916000001,
0.10342739816000002,
0.11070076916000002,
0.10856337616000002,
0.11255649116000001,
0.10225405916000001,
0.13376229816000001,
0.11822360716000001,
0.10834049416000001,
0.11689961116000001,
0.10843362216,
0.11496295016000001,
0.12255424516000002,
0.10723166616000002,
0.12298267716000001,
0.11773826016000001,
0.12864443816
]
},
{
"command": "pnpr@main",
"mean": 0.11675440041000001,
"stddev": 0.00833897782361016,
"median": 0.11615232566000001,
"user": 0.036046304999999994,
"system": 0.021163120000000004,
"min": 0.10472016716000002,
"max": 0.13014077816,
"times": [
0.11266012416000001,
0.12301487516000001,
0.10472016716000002,
0.12063376516000002,
0.12403623116000002,
0.10514552716000002,
0.12865098816,
0.11567627316000001,
0.10736413516000001,
0.10491502616000001,
0.11656963216000002,
0.10717212116000001,
0.11047436316000002,
0.11668739916000001,
0.11808874416000001,
0.12872222516,
0.13014077816,
0.12915722816,
0.11208516816000001,
0.11573501916000001,
0.11064047716000001,
0.11159751616000001,
0.12730293616,
0.12091488916000001
]
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.540490206006667,
"stddev": 0.3533253393190046,
"median": 1.5379901633400002,
"user": 1.4966666288888886,
"system": 0.42673075555555556,
"min": 1.00097066234,
"max": 2.2166128773400002,
"times": [
1.4565396023400001,
1.56391511134,
1.00097066234,
1.64178211234,
1.79383826834,
1.5379901633400002,
1.13048087034,
1.52228218634,
2.2166128773400002
]
},
{
"command": "pacquet@main",
"mean": 1.351024467451111,
"stddev": 0.38154632355207113,
"median": 1.4149266253400001,
"user": 1.3247482955555556,
"system": 0.37711275555555557,
"min": 0.70478041134,
"max": 1.9285786713400002,
"times": [
1.53438622534,
1.9285786713400002,
1.3929458193400002,
1.57649223034,
1.1051096413400001,
1.4149266253400001,
0.70478041134,
0.9026910663400001,
1.59930951634
]
},
{
"command": "pnpm@HEAD",
"mean": 4.240957395117778,
"stddev": 0.4960151611297315,
"median": 4.27292244934,
"user": 6.281725295555555,
"system": 0.47368319999999997,
"min": 3.40468976634,
"max": 4.88252271334,
"times": [
4.22263580034,
4.87477691934,
4.3294366463400005,
4.38013976534,
4.21341741834,
4.88252271334,
4.27292244934,
3.40468976634,
3.58807507734
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.678785556420001,
"stddev": 0.08748568890515197,
"median": 4.6749446172199995,
"user": 2.6351381199999997,
"system": 1.9243316599999996,
"min": 4.53209039722,
"max": 4.82522866722,
"times": [
4.7101267162200005,
4.67366755922,
4.67622167522,
4.61884250622,
4.6543697252200005,
4.53209039722,
4.6873212552200005,
4.8031458252200006,
4.60684123722,
4.82522866722
]
},
{
"command": "pacquet@main",
"mean": 4.65091071612,
"stddev": 0.14290649510149575,
"median": 4.63868642272,
"user": 2.5035386199999996,
"system": 1.8878586599999998,
"min": 4.47380552122,
"max": 4.938858806220001,
"times": [
4.50634804622,
4.6159768232200005,
4.47380552122,
4.51664542622,
4.59172315422,
4.66139602222,
4.7072540942200005,
4.79050039122,
4.70659887622,
4.938858806220001
]
},
{
"command": "pnpr@HEAD",
"mean": 3.807635399920001,
"stddev": 0.09927816129932245,
"median": 3.81687076472,
"user": 2.30084732,
"system": 2.0652969600000004,
"min": 3.65551047922,
"max": 3.96465774422,
"times": [
3.65551047922,
3.82783558822,
3.92659440122,
3.8059059412200003,
3.7521042012200003,
3.87314110422,
3.96465774422,
3.67879996922,
3.82827880122,
3.76352576922
]
},
{
"command": "pnpr@main",
"mean": 3.79063822672,
"stddev": 0.10376466293635805,
"median": 3.7930078962200002,
"user": 2.2546958200000002,
"system": 2.08780116,
"min": 3.6637779862200004,
"max": 3.9991439702200005,
"times": [
3.8529126232200004,
3.8136937102200004,
3.8693727752200004,
3.77232208222,
3.7177262332200005,
3.9991439702200005,
3.8302458562200004,
3.67527357322,
3.71191345722,
3.6637779862200004
]
}
]
} |
|
The 1. Re-running the identical commit produces completely different deltas. Same code, same PR, two runs:
A real regression does not move from +22% to +62% to +10% on unchanged code. Bencher compares against a historical baseline from 2. The in-run HEAD wins 4, main wins 4, every gap inside the reported ±σ. Summed, HEAD is 0.6% faster. 3. The added work is ~12 µs. The change adds one Written by an agent (Claude Code, claude-opus-5). |
Picks up #13609, which normalizes a BOM or CRLF line endings before splitting the combined `pnpm-lock.yaml` into its env and main documents, and #13621, which passes the restart tests' log path through `process.argv` instead of interpolating it into a JS string literal. Neither touches the files this branch edits, so the merge is clean.
Summary
Fixes #13606: pnpm 12 discarded a
pnpm-lock.yamlthat pnpm 11 wrote as two YAML documents, warnedmultiple YAML documents detected; use from_multiple or from_multiple_with_options, and re-resolved every dependency from the registry — so the lockfile stopped pinning anything.extract_main_document/extract_env_documentinpnpm/crates/lockfile/src/yaml_documents.rssplit the combined lockfile by matching the literal markers---\nand\n---\n. A lockfile pacquet did not write may not use LF: acore.autocrlfcheckout on Windows (the reporter's platform) gives CRLF, and an editor may add a UTF-8 BOM. Neither marker matches then, soextract_main_documentfell through toreturn content— the whole two-document file — whichserde_saphyr::from_str_with_optionsrejected with exactly the reported error, at the line where the second document starts.The fix normalizes the whole file (strip a leading BOM, rewrite CRLF as LF) inside both extractors, so every caller is covered:
Lockfile::parse,Lockfile::wanted_exists_in_dir,EnvLockfile::read,EnvLockfile::write, andsave_value_to_path.Cowkeeps the common LF path allocation-free.save_value_to_pathalready did this normalization inline and now shares the helper instead.No TypeScript counterpart is needed.
pnpm11/lockfile/fs/src/yamlDocuments.tsalready normalizes CRLF insideextractMainDocument/extractEnvDocumentand strips the BOM at every read site; this brings pacquet to the behavior the TypeScript CLI already has.Tests added: CRLF and BOM document splits in
yaml_documents/tests.rs, a loader-level regression asserting a CRLF combined lockfile loads identically to the equivalent main-only lockfile, and a CRLF env-document read.Note on local verification:
just readyis green except forpackage_manager_check::a_command_outside_the_install_family_records_the_pinned_package_manageranda_package_manager_field_with_an_integrity_hash_matches_the_running_version, which fail onmaintoo — they bootstrap the pinned[email protected]from the real registry and that version is not published yet (npm'snext-12is still12.0.0-beta.3). They fail before any lockfile is read.Squash Commit Body
Checklist
already linked to it solves it.
pnpm/port, or the description notes what still needs porting.pnpm changeset) if this PR changes any publishedpackage. Keep it short and written for pnpm users — it becomes a release note.
Written by an agent (Claude Code, claude-opus-5).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
Bug Fixes
pnpm installhandling of lockfiles with CRLF line endings, UTF-8 BOMs, or leading environment documents.Tests