Repository navigation
fix(package-manifest): read package.json files that start with a UTF-8 BOM - #13327
Conversation
…8 BOM serde_json rejects a leading byte order mark, so a manifest carrying one failed the whole read with "expected value at line 1 column 1". Workspace discovery aborted on it, which made pnpm 12 unusable in repositories that keep such a manifest on purpose — vitejs/vite ships playground/resolve/utf8-bom-package/package.json and matches it with its workspace patterns. Route every manifest parse through parse_manifest / parse_manifest_bytes, which drop the BOM first. pnpm decodes manifests through strip-bom and TextDecoder, so both stacks now accept the same files: project manifests, dependency manifests read from node_modules, and the package.json bundled in a tarball. The BOM only disappears from a file once a real change makes the writer emit the manifest afresh. A manifest that really is malformed now reports its path, which the workspace-discovery diagnostic previously omitted. Closes #13311
|
Warning Review limit reached
Next review available in: 8 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (18)
📝 WalkthroughWalkthroughChangesManifest parsing and consumers
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant WorkspaceDiscovery
participant PackageManifest
participant parse_manifest_bytes
participant SerdeJson
WorkspaceDiscovery->>PackageManifest: Read package.json bytes
PackageManifest->>parse_manifest_bytes: Parse manifest bytes
parse_manifest_bytes->>SerdeJson: Parse BOM-stripped JSON
SerdeJson-->>parse_manifest_bytes: Manifest value or parse error
parse_manifest_bytes-->>PackageManifest: Parsed manifest
PackageManifest-->>WorkspaceDiscovery: Discovered project or path-aware error
Assessment against linked issues
Suggested labels: Suggested reviewers: ✨ Finishing Touches🧪 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 BOM-prefixed package.json parsing across pacquet manifest reads
AI Description
Diagram
High-Level Assessment
Files changed (13)
|
Confidence Score: 5/5The PR appears safe to merge. The previously reported bin-linking and packed-manifest failures are addressed by routing their reachable readers through the shared BOM-aware parsers, and no blocking failure remains. Reviews (2): Last reviewed commit: "fix(package-manifest): strip the BOM on ..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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.
Inline comments:
In `@pnpm/crates/cli/src/cli_args/deps_tree/finders.rs`:
- Line 215: Update read_manifest_from_cafs in
pnpm/crates/cli/src/cli_args/deps_tree/finders.rs at lines 215-215 to parse CAFS
manifest bytes through parse_manifest_bytes instead of direct JSON parsing, and
add coverage for BOM-prefixed CAFS manifests. Retain the broad
dependency-manifest claim in .changeset/read-bom-prefixed-manifests.md at lines
5-5 once the CAFS path is covered.
In `@pnpm/crates/executor/src/lifecycle/tests.rs`:
- Around line 449-451: Strengthen the assertion around the
LifecycleScriptError::ReadManifest match in the lifecycle test to validate the
manifest path diagnostic, not just the Parse variant. Destructure the embedded
path and assert it equals pkg_root.join("package.json"), or verify the rendered
error includes that path, while preserving the existing error-variant check.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 13fd8a5f-e3c7-4309-a5af-4fc49dbd3b04
📒 Files selected for processing (13)
.changeset/read-bom-prefixed-manifests.mdpnpm/crates/cli/src/cli_args/deps_tree/build.rspnpm/crates/cli/src/cli_args/deps_tree/finders.rspnpm/crates/cli/src/cli_args/deps_tree/render.rspnpm/crates/executor/src/lifecycle/tests.rspnpm/crates/global/src/lib.rspnpm/crates/package-manager/src/create_virtual_store.rspnpm/crates/package-manifest/src/lib.rspnpm/crates/package-manifest/src/tests.rspnpm/crates/tarball/src/lib.rspnpm/crates/tarball/src/tests.rspnpm/crates/workspace/src/project_manifest/tests.rspnpm/crates/workspace/src/projects/tests.rs
Code Review by Qodo
Context used✅ Compliance rules (platform):
24 rules 1. Manifest dep graph expansion
|
Micro-Benchmark ResultsLinux |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #13327 +/- ##
==========================================
- Coverage 87.05% 87.03% -0.02%
==========================================
Files 532 533 +1
Lines 91601 91692 +91
==========================================
+ Hits 79741 79805 +64
- Misses 11860 11887 +27 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Integrated-Benchmark Report (Linux)Commit: Each scenario reports direct installs and pnpr installs. 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.5035484295800003,
"stddev": 0.15015097875641273,
"median": 2.47984798418,
"user": 1.70353146,
"system": 1.3230420199999997,
"min": 2.34725424268,
"max": 2.75207237568,
"times": [
2.35907479068,
2.49126597468,
2.75207237568,
2.38819883868,
2.46842999368,
2.64678415768,
2.54232597968,
2.69119599168,
2.34888195068,
2.34725424268
]
},
{
"command": "pacquet@main",
"mean": 2.5073663072800003,
"stddev": 0.15074987438623988,
"median": 2.44570748518,
"user": 1.6811112600000002,
"system": 1.3490560200000001,
"min": 2.35965638868,
"max": 2.72117497168,
"times": [
2.42403131068,
2.36968557068,
2.41062757968,
2.46738365968,
2.71815873568,
2.70135065968,
2.72117497168,
2.37438987168,
2.52720432468,
2.35965638868
]
},
{
"command": "pnpr@HEAD",
"mean": 1.44015764168,
"stddev": 0.0966367793129502,
"median": 1.43561527468,
"user": 1.18337776,
"system": 1.1751221199999997,
"min": 1.33870419868,
"max": 1.6525997436800002,
"times": [
1.3592112086800001,
1.6525997436800002,
1.42830429568,
1.45313505768,
1.37065408768,
1.34834560468,
1.51765988968,
1.49003607668,
1.33870419868,
1.44292625368
]
},
{
"command": "pnpr@main",
"mean": 1.4398298081799998,
"stddev": 0.12651165330613393,
"median": 1.39258715018,
"user": 1.1945393599999998,
"system": 1.1570606199999998,
"min": 1.34033936568,
"max": 1.72327552568,
"times": [
1.72327552568,
1.51630009968,
1.40759718768,
1.37954502268,
1.3578301696800001,
1.3516586026800002,
1.34197201268,
1.57415081768,
1.4056292776800001,
1.34033936568
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.25288565326,
"stddev": 0.00546842073294813,
"median": 0.25276358916,
"user": 0.20290555999999998,
"system": 0.5079132599999999,
"min": 0.24103873066,
"max": 0.26129443266,
"times": [
0.25187524666,
0.25084764166,
0.25245953766,
0.25337523166000003,
0.24103873066,
0.25444206466,
0.25080923266,
0.25964677366,
0.26129443266,
0.25306764066000004
]
},
{
"command": "pacquet@main",
"mean": 0.25348965616,
"stddev": 0.005465256536136277,
"median": 0.25269288066,
"user": 0.19868495999999997,
"system": 0.51975386,
"min": 0.24847240766000003,
"max": 0.26592625466,
"times": [
0.24882078266000002,
0.25534813166000003,
0.24949140666000003,
0.24847240766000003,
0.25479969866,
0.25058606266,
0.25534721766,
0.25716088966,
0.24894370966,
0.26592625466
]
},
{
"command": "pnpr@HEAD",
"mean": 0.26720757596,
"stddev": 0.010285401733955559,
"median": 0.26504653866000005,
"user": 0.20669195999999998,
"system": 0.5167555599999999,
"min": 0.25456717166000004,
"max": 0.28396831666,
"times": [
0.28241842566,
0.25964486466000003,
0.27181914066,
0.27296459966000003,
0.26542602166,
0.26466705566000004,
0.25853847166000005,
0.25456717166000004,
0.25806169166000004,
0.28396831666
]
},
{
"command": "pnpr@main",
"mean": 0.2681556714600001,
"stddev": 0.0072513805715520374,
"median": 0.26891326216,
"user": 0.21971725999999997,
"system": 0.50901636,
"min": 0.25442001066000003,
"max": 0.27855408066000004,
"times": [
0.27521214866000004,
0.27039258466000005,
0.26689864766000004,
0.26137112766000004,
0.27433726166,
0.25442001066000003,
0.27017668666,
0.26254432866000005,
0.26764983766,
0.27855408066000004
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.7629781425000006,
"stddev": 0.01284309145985408,
"median": 2.7601796092000006,
"user": 1.8915793,
"system": 1.31190962,
"min": 2.7416182097000004,
"max": 2.7895871677,
"times": [
2.7599839117000005,
2.7603753067000003,
2.7416182097000004,
2.7667070967000003,
2.7651220547000004,
2.7559771287,
2.7895871677,
2.7581699437,
2.7562689807000003,
2.7759716247000004
]
},
{
"command": "pacquet@main",
"mean": 2.7389212956,
"stddev": 0.010196414472019093,
"median": 2.7402071122000002,
"user": 1.8391319,
"system": 1.3415954199999998,
"min": 2.7194403277,
"max": 2.7517667767000002,
"times": [
2.7273820217,
2.7517662987000002,
2.7517667767000002,
2.7361106377000004,
2.7402975937000003,
2.7421715257000003,
2.7401166307,
2.7194403277,
2.7459356427,
2.7342255007000005
]
},
{
"command": "pnpr@HEAD",
"mean": 1.5840130399999999,
"stddev": 0.1632030939098107,
"median": 1.5186407417,
"user": 1.1935194,
"system": 1.1826873199999999,
"min": 1.4461993337,
"max": 1.8826712417,
"times": [
1.4470033947,
1.5100955587,
1.8826712417,
1.5437216637,
1.5153570757000001,
1.5219244077,
1.8595936407,
1.6559604567000001,
1.4461993337,
1.4576036266999999
]
},
{
"command": "pnpr@main",
"mean": 1.6291076196999998,
"stddev": 0.13084264529953513,
"median": 1.6213222847,
"user": 1.1894917000000003,
"system": 1.1920469199999997,
"min": 1.4512765627,
"max": 1.8517298007,
"times": [
1.4512765627,
1.4840321957,
1.6197332057,
1.5310799767,
1.7990530757,
1.6231283287,
1.6229113636999999,
1.7313576727,
1.5767740147,
1.8517298007
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.5835764688400001,
"stddev": 0.01603402258802754,
"median": 0.5788161167400001,
"user": 0.6872912999999998,
"system": 0.6891307799999999,
"min": 0.5616186287400001,
"max": 0.6138971727400001,
"times": [
0.5736657397400001,
0.5822163007400001,
0.57541593274,
0.5746659137400001,
0.5748104457400001,
0.6138971727400001,
0.6071437407400001,
0.5893737927400001,
0.5829570207400001,
0.5616186287400001
]
},
{
"command": "pacquet@main",
"mean": 0.56339033354,
"stddev": 0.009829765672330744,
"median": 0.5606637157400001,
"user": 0.6995099999999999,
"system": 0.66294958,
"min": 0.55189365674,
"max": 0.58270691774,
"times": [
0.5593702667400001,
0.55668960574,
0.58270691774,
0.55189365674,
0.5640596157400001,
0.5741862587400001,
0.5714936747400001,
0.56195716474,
0.55688910974,
0.5546570647400001
]
},
{
"command": "pnpr@HEAD",
"mean": 0.30172493464,
"stddev": 0.00936455359033775,
"median": 0.29768627074,
"user": 0.1850186,
"system": 0.52098768,
"min": 0.28816567674,
"max": 0.31841831074,
"times": [
0.30822703274,
0.28816567674,
0.29775945774,
0.29513365974,
0.29526283574,
0.30616033674,
0.31306569074,
0.29761308374,
0.31841831074,
0.29744326174
]
},
{
"command": "pnpr@main",
"mean": 0.30081030884000004,
"stddev": 0.008436015761022176,
"median": 0.30086600374,
"user": 0.2005556,
"system": 0.49041988,
"min": 0.28511898774,
"max": 0.31138548374,
"times": [
0.30582118974,
0.29490970874,
0.29842163374,
0.31138548374,
0.30828658174,
0.29261173474,
0.28511898774,
0.30331037373999997,
0.29839326574,
0.30984412874
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.9058553091800001,
"stddev": 0.007027879316018927,
"median": 1.90347815368,
"user": 0.9494090199999997,
"system": 0.7635936799999999,
"min": 1.89855016568,
"max": 1.91801417068,
"times": [
1.9055394166800002,
1.9078617416800001,
1.91801417068,
1.89855016568,
1.90031657468,
1.9123742696800001,
1.90103600768,
1.90141689068,
1.91451902568,
1.89892482868
]
},
{
"command": "pacquet@main",
"mean": 1.89676050258,
"stddev": 0.010655992352445019,
"median": 1.89376768918,
"user": 0.9581605199999998,
"system": 0.7537450800000001,
"min": 1.88673605768,
"max": 1.91806384868,
"times": [
1.91806384868,
1.88850011268,
1.89773943068,
1.88697026568,
1.90237462868,
1.88673605768,
1.9096711826800001,
1.88979594768,
1.89830664968,
1.8894469016800002
]
},
{
"command": "pnpr@HEAD",
"mean": 0.29680207508000006,
"stddev": 0.006799946132908829,
"median": 0.29737455418000003,
"user": 0.18742102,
"system": 0.5164981799999999,
"min": 0.28618903768000004,
"max": 0.30808847068,
"times": [
0.29773355668,
0.29232667268,
0.29930096368000003,
0.29776542668,
0.29293125168,
0.28618903768000004,
0.29701555168000005,
0.30634542568,
0.30808847068,
0.29032439368
]
},
{
"command": "pnpr@main",
"mean": 0.29638369818,
"stddev": 0.0076270250465781545,
"median": 0.29475529418,
"user": 0.18752892,
"system": 0.50384508,
"min": 0.28860722468,
"max": 0.31635037368,
"times": [
0.29509195368,
0.29306231068000005,
0.29306198368,
0.29085262968000003,
0.29750701368000004,
0.29627836868,
0.29441863468,
0.31635037368,
0.29860648868,
0.28860722468
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.36494966094000003,
"stddev": 0.0070037406658207775,
"median": 0.36573135623999997,
"user": 0.35239447999999995,
"system": 0.07570683999999998,
"min": 0.35457025974,
"max": 0.37397821374,
"times": [
0.35834407874,
0.36048806574000003,
0.35457025974,
0.35703939074,
0.36911207974,
0.37164294874000003,
0.36605496074,
0.37397821374,
0.36540775174,
0.37285885974
]
},
{
"command": "pacquet@main",
"mean": 0.35881452334,
"stddev": 0.008303309939693557,
"median": 0.35545939074,
"user": 0.34956018,
"system": 0.06922383999999998,
"min": 0.34907257074000003,
"max": 0.37229208374,
"times": [
0.36523168374000003,
0.34959100674,
0.35309990774,
0.36816870374,
0.35655620474,
0.35395520274000003,
0.35436257674,
0.34907257074000003,
0.36581529274,
0.37229208374
]
},
{
"command": "pnpr@HEAD",
"mean": 0.0890118651036364,
"stddev": 0.0028120683029372357,
"median": 0.08885974774000001,
"user": 0.0193120496969697,
"system": 0.012920558181818179,
"min": 0.08473401974000001,
"max": 0.09518933374,
"times": [
0.08507014774,
0.08659964674000001,
0.09063118274000001,
0.09491131874000001,
0.08896226074000001,
0.08617165574,
0.09218017974,
0.08862259074,
0.09021521974,
0.08676522674,
0.08473401974000001,
0.09450905774000001,
0.08885974774000001,
0.09275896174,
0.08864339974000002,
0.08957275274000001,
0.08756611074000001,
0.09114787374000001,
0.09518933374,
0.08658073874000001,
0.09070578474000002,
0.09194614974000001,
0.08627684774000001,
0.08553786874000001,
0.08773416474000001,
0.08930543074000001,
0.08921677874000002,
0.09018670474000001,
0.08594251574000002,
0.08696050574000001,
0.08697170374000002,
0.08971862374000002,
0.08719704374000001
]
},
{
"command": "pnpr@main",
"mean": 0.08866090264322583,
"stddev": 0.0030033561612893937,
"median": 0.08740506074000001,
"user": 0.02229991870967742,
"system": 0.00936682129032258,
"min": 0.08551301474,
"max": 0.09781695674000002,
"times": [
0.08905130274,
0.08645612174000002,
0.09399410074000002,
0.09007423574000001,
0.08556073274,
0.09222565974000001,
0.08553547474,
0.08694839574000002,
0.08867144674,
0.08860462174000001,
0.08651894774,
0.08740506074000001,
0.08643908474,
0.08724655174000001,
0.08592501874000001,
0.08712274774,
0.09028095474000002,
0.08731204874000001,
0.08577677674,
0.08579951074000002,
0.09251491474000001,
0.08551301474,
0.09122059674,
0.08599838774000002,
0.08887763074,
0.09347945574000001,
0.08933644374000001,
0.08822223974000001,
0.08712248074000001,
0.09781695674000002,
0.09143706574000002
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.4916706956,
"stddev": 0.10195813452799769,
"median": 4.457564918999999,
"user": 1.8445568599999997,
"system": 1.4386991999999998,
"min": 4.4161665725,
"max": 4.7608758325,
"times": [
4.554819084499999,
4.4381038015,
4.4161665725,
4.4713272024999995,
4.7608758325,
4.4347961645,
4.460803277499999,
4.454326560499999,
4.442004069499999,
4.483484390499999
]
},
{
"command": "pacquet@main",
"mean": 4.5055206477,
"stddev": 0.07493391368548956,
"median": 4.4812781379999995,
"user": 1.82572896,
"system": 1.4547022,
"min": 4.4299832125,
"max": 4.6682780015,
"times": [
4.5545184784999995,
4.454680993499999,
4.4513585245,
4.5148052535,
4.6682780015,
4.502178843499999,
4.4299832125,
4.4452718695,
4.4603774325,
4.5737538675
]
},
{
"command": "pnpr@HEAD",
"mean": 3.5465621219,
"stddev": 0.15053590646693385,
"median": 3.4850184855,
"user": 1.28389756,
"system": 1.2701703,
"min": 3.4442750395,
"max": 3.8397493995,
"times": [
3.5011853935,
3.4779800255,
3.8397493995,
3.4442750395,
3.5059802505,
3.4683647755,
3.4548432155,
3.8193904915,
3.4920569455,
3.4617956825
]
},
{
"command": "pnpr@main",
"mean": 3.5219095366,
"stddev": 0.1197405552317194,
"median": 3.4642938315,
"user": 1.2963239599999998,
"system": 1.2368777,
"min": 3.4386062225000003,
"max": 3.8126658375,
"times": [
3.4643150305,
3.4386062225000003,
3.4545818725,
3.5209002185,
3.5186629105000002,
3.4500329515,
3.4477819615,
3.8126658375,
3.4642726325,
3.6472757285
]
}
]
} |
|
| Project | pnpm's project |
| Branch | pr/13327 |
| Testbed | pnpr |
⚠️ WARNING: No Threshold found!Without a Threshold, no Alerts will ever be generated.
Click here to create a new Threshold
For more information, see the Threshold documentation.
To only post results if a Threshold exists, set the--ci-only-thresholdsflag.
Click to view all benchmark results
| Benchmark | Latency | milliseconds (ms) |
|---|---|---|
| isolated-linker.fresh-install.cold-cache.cold-store | 📈 view plot | 1,446.20 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 286.19 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 288.17 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 84.73 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,338.70 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,444.28 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 254.57 ms |
Extraction accepting a BOM-prefixed package.json is not enough on its own: bin linking, dependency pruning, the CAFS manifest lookup behind `pnpm list`, `pnpm publish <tarball>`, and the archive-subdirectory manifest read all deserialized the same bytes with serde_json directly, so a package Vite-style manifest would still fail the install after extraction had accepted it. Route them through parse_manifest / parse_manifest_bytes as well, along with the manifest reads behind `packageManager` detection, dlx, pack --app, stage, self-update and `pnpm with`. pacquet-cmd-shim and pacquet-publish gain a dependency on pacquet-package-manifest for the shared helpers. The lifecycle-script test now asserts the reported path, not just the error variant, since reporting the path is what the variant exists for.
|
Follow-up in ef92260 addresses the review findings; two Qodo points I am not acting on, with reasons. Acted on — the P1s were right, and they pointed at a real hole: extraction accepting a BOM-prefixed manifest was not enough, because bin linking re-parsed the same bytes and would have failed the install anyway. Every remaining Not acted on — dedicated diagnostic code for Not acted on — Written by an agent (Claude Code, claude-opus-5[1m]). |
|
Code review by qodo was updated up to the latest commit ef92260 |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
…8 BOM (pnpm#13327) serde_json rejects a leading byte order mark, so a manifest carrying one failed the whole read with "expected value at line 1 column 1". Workspace discovery aborted on it, which made pnpm 12 unusable in repositories that keep such a manifest on purpose — vitejs/vite ships playground/resolve/utf8-bom-package/package.json and matches it with its workspace patterns. Route every manifest parse through parse_manifest / parse_manifest_bytes, which drop the BOM first. pnpm decodes manifests through strip-bom and TextDecoder, so both stacks now accept the same files: project manifests, dependency manifests read from node_modules, and the package.json bundled in a tarball. The BOM only disappears from a file once a real change makes the writer emit the manifest afresh. A manifest that really is malformed now reports its path, which the workspace-discovery diagnostic previously omitted. Closes pnpm#13311
Summary
serde_jsonrejects a leading UTF-8 byte order mark, so anypackage.jsoncarrying one failed to parse withexpected value at line 1 column 1. During workspace discovery that aborted the whole command, which made pnpm 12 unusable in repositories that keep such a manifest on purpose —vitejs/viteshipsplayground/resolve/utf8-bom-package/package.jsonand matches it with its workspace patterns.Every manifest parse now goes through
parse_manifest/parse_manifest_bytes, which drop a leading BOM first. The TypeScript CLI already decodes manifests throughstrip-bom(project manifests, cafs) andload-json-file'sTextDecoder(dependency manifests), so this is a pacquet-only fix that brings the two stacks back in line — no TypeScript counterpart is needed.Covered read paths: project manifests (workspace discovery),
safe_read_package_json_from_dir(lifecycle scripts, directory fetcher), bin linking (pacquet-cmd-shimandpacquet-package-manager::link_bins), dependency pruning, global packages, virtual-store build detection,pnpm list/whymanifest reads including the CAFS lookup, thepackage.jsonbundled inside a tarball and in an archive subdirectory (pnpm'saddFilesFromTarballstrips a BOM there too),pnpm publish <tarball>, and thepackageManager/ dlx /pack --app/ stage / self-update /pnpm withmanifest reads.package.yamlalready tolerated a BOM; a test now pins that.Extraction alone was not enough: a BOM-prefixed dependency manifest extracted fine but then failed bin linking with
ParseManifest, which would have broken the install anyway.pacquet-cmd-shimandpacquet-publishgained a dependency onpacquet-package-manifestfor the shared helpers.Reading a BOM-prefixed manifest never rewrites the file on its own, so the BOM survives until a real change makes the writer emit the manifest afresh — the same as what pnpm writes.
Also, a manifest that really is malformed now reports its path. The reported diagnostic was four repetitions of
expected value at line 1 column 1with no indication of which file was at fault.Reproduction from the issue, with this branch built:
Closes #13311
Squash Commit Body
Checklist
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[1m]).