Repository navigation
feat(cli): warn on global operations under sudo, refuse them in v12 - #13495
Conversation
pnpm keeps global packages and configuration in the invoking user's home directory, so 'sudo pnpm add -g', 'sudo pnpm setup', and 'sudo pnpm self-update' never do what the user wants: they target root's home and leave root-owned files behind. Other package managers settled on the same direction — npm 9 removed its SUDO_UID chown machinery and just tells users not to use sudo, and Homebrew refuses root outright. Both stacks now fail fast with ERR_PNPM_SUDO_NOT_SUPPORTED when the effective uid is 0, SUDO_USER names a non-root user, and the command mutates home-directory state: setup, self-update, or a global write (add, install, remove, update, runtime, approve-builds, bare link, config set/delete -g). Read-only global commands (bin, root, prefix, list, outdated, config get, ...) still work, and plain root sessions without SUDO_USER are unaffected. Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
📝 WalkthroughWalkthroughpnpm adds sudo detection for global state mutations in the JavaScript and Rust CLI paths. Read-only global commands and non-global operations remain allowed. The change adds tests and Changesets for warning and error behavior. ChangesSudo guard
Estimated code review effort: 4 (Complex) | ~45 minutes Suggested labels: Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant CLI as pnpm CLI
participant Guard as sudo guard
participant Reporter as reporter or stderr
CLI->>Guard: validate command and sudo environment
Guard->>Reporter: emit warning for blocked JavaScript operation
Guard-->>CLI: return diagnostic for blocked Rust operation
Guard-->>CLI: allow read-only or non-global operation
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ESLint
ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration. 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 Qodofeat(cli): refuse global writes under sudo (fail fast with ERR_PNPM_SUDO_NOT_SUPPORTED)
AI Description
Diagram
High-Level Assessment
Files changed (8)
|
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the previously questioned Reviews (4): Last reviewed commit: "fix(cli): print the sudo warning when no..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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/sudo_guard.rs`:
- Around line 76-80: Update the Link handling in
pnpm/crates/cli/src/cli_args/sudo_guard.rs around CliCommand::Link so an
explicitly global link returns the existing “pnpm link --global” replacement
regardless of package_paths; preserve the current no-argument behavior. Add a
regression case in pnpm/crates/cli/src/cli_args/sudo_guard/tests.rs covering
“pnpm link --global <package>” and asserting rejection with the matching
replacement output.
🪄 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: 00255689-b377-4e0e-bd1d-ebd9e66c5482
📒 Files selected for processing (8)
.changeset/refuse-sudo-global.mdpnpm/crates/cli/src/cli_args.rspnpm/crates/cli/src/cli_args/sudo_guard.rspnpm/crates/cli/src/cli_args/sudo_guard/tests.rspnpm/crates/cli/src/lib.rspnpm11/pnpm/src/checkSudo.test.tspnpm11/pnpm/src/checkSudo.tspnpm11/pnpm/src/main.ts
Micro-Benchmark ResultsLinux |
Code Review by Qodo
1.
|
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13495 +/- ##
==========================================
+ Coverage 87.86% 88.08% +0.22%
==========================================
Files 549 608 +59
Lines 96091 99032 +2941
==========================================
+ Hits 84429 87235 +2806
- Misses 11662 11797 +135 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Config set/delete write to the global config file by default: --location wins, and without it the operation is global even with no --global flag. The guard previously keyed on the explicit flag alone, so a bare 'sudo pnpm config set' slipped past it. Both stacks now resolve the effective scope (pacquet reuses the config command's resolve_global) and only --location=project writes stay allowed under sudo. Co-Authored-By: Claude Fable 5 <[email protected]>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pnpm/crates/cli/src/cli_args/sudo_guard/tests.rs (1)
74-75: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse a regular rationale comment, or remove this rustdoc.
///is for API contracts; this private-test doc repeats the cases asserted below. Use//only if retaining the scope-resolution rationale.As per coding guidelines, “Use rustdoc comments for public API contracts” and “Do not duplicate test behavior in documentation.”
🤖 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/cli/src/cli_args/sudo_guard/tests.rs` around lines 74 - 75, Replace the rustdoc comments above the private test with regular // comments, or remove them entirely. If retaining context, keep only the scope-resolution rationale and avoid documenting the test cases or assertions covered below.Sources: Coding guidelines, 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/cli/src/cli_args/sudo_guard/tests.rs`:
- Around line 74-75: Replace the rustdoc comments above the private test with
regular // comments, or remove them entirely. If retaining context, keep only
the scope-resolution rationale and avoid documenting the test cases or
assertions covered below.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 3ca8ffae-3e84-4804-8df4-0a91fb63c8dc
📒 Files selected for processing (6)
pnpm/crates/cli/src/cli_args/config.rspnpm/crates/cli/src/cli_args/sudo_guard.rspnpm/crates/cli/src/cli_args/sudo_guard/tests.rspnpm11/pnpm/src/checkSudo.test.tspnpm11/pnpm/src/checkSudo.tspnpm11/pnpm/src/main.ts
|
Code review by qodo was updated up to the latest commit b6e54dc |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
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.5382231577,
"stddev": 0.14815466333880287,
"median": 2.514594155,
"user": 1.5495970999999997,
"system": 1.26672356,
"min": 2.3652343030000003,
"max": 2.781154677,
"times": [
2.781154677,
2.450068082,
2.388102462,
2.3652343030000003,
2.7017503950000004,
2.551476805,
2.4777115050000003,
2.564827449,
2.3981631090000004,
2.70374279
]
},
{
"command": "pacquet@main",
"mean": 2.5390875234000005,
"stddev": 0.1891802818333222,
"median": 2.521125024,
"user": 1.5095071,
"system": 1.29712166,
"min": 2.335311346,
"max": 2.772833894,
"times": [
2.7373649030000005,
2.362391342,
2.358698307,
2.7386758880000004,
2.6977843550000005,
2.345565151,
2.772833894,
2.335311346,
2.421756078,
2.62049397
]
},
{
"command": "pnpr@HEAD",
"mean": 1.4971734942000001,
"stddev": 0.14670807346178302,
"median": 1.462954564,
"user": 1.0413118000000001,
"system": 1.11305486,
"min": 1.3440427799999999,
"max": 1.7568303029999999,
"times": [
1.416492533,
1.509416595,
1.693596375,
1.7568303029999999,
1.6001684600000001,
1.361628824,
1.368900267,
1.529061057,
1.391597748,
1.3440427799999999
]
},
{
"command": "pnpr@main",
"mean": 1.5693943220000002,
"stddev": 0.17009088792946145,
"median": 1.613794691,
"user": 1.0442202999999999,
"system": 1.15491596,
"min": 1.343817808,
"max": 1.758480761,
"times": [
1.745349107,
1.7213100239999999,
1.695490756,
1.758480761,
1.538123044,
1.3837645729999999,
1.444706525,
1.6894663380000001,
1.343817808,
1.373434284
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.29393924436,
"stddev": 0.019734667783567587,
"median": 0.28912133996,
"user": 0.24582542,
"system": 0.5566023999999999,
"min": 0.26682051996,
"max": 0.33070611095999997,
"times": [
0.28657979196,
0.28589558996,
0.26871397395999996,
0.33070611095999997,
0.31379545296,
0.26682051996,
0.28733933396,
0.30461936396,
0.29090334596,
0.30401895996
]
},
{
"command": "pacquet@main",
"mean": 0.27696346675999994,
"stddev": 0.021423699214234617,
"median": 0.27168373995999995,
"user": 0.21867482000000002,
"system": 0.5457845000000001,
"min": 0.25484473996,
"max": 0.33231182796,
"times": [
0.33231182796,
0.28179011496,
0.27806420896,
0.26640207596,
0.27525033196,
0.25484473996,
0.26811714795999997,
0.26703465096,
0.26219984896,
0.28361971996
]
},
{
"command": "pnpr@HEAD",
"mean": 0.29822055975999995,
"stddev": 0.017725296046108945,
"median": 0.29699570696,
"user": 0.22431362000000005,
"system": 0.5801996,
"min": 0.27448815496,
"max": 0.32517268196,
"times": [
0.31029965896,
0.28456400796,
0.29215879695999997,
0.28937602596,
0.32517268196,
0.30933913996,
0.30183261695999997,
0.27565941796,
0.27448815496,
0.31931509596
]
},
{
"command": "pnpr@main",
"mean": 0.30913040816,
"stddev": 0.03393027664234584,
"median": 0.29554765496,
"user": 0.24879282000000003,
"system": 0.5782673,
"min": 0.28016242195999996,
"max": 0.39639491696,
"times": [
0.31597568396,
0.29022048695999997,
0.29309252496,
0.31829420595999997,
0.29776592896,
0.28016242195999996,
0.29332938096,
0.28421469096,
0.32185383996,
0.39639491696
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 3.31360406916,
"stddev": 0.3268926652872418,
"median": 3.3377039692599997,
"user": 2.90861248,
"system": 2.4436844399999997,
"min": 2.7029740247599996,
"max": 3.75126047776,
"times": [
2.7029740247599996,
2.89211643176,
3.34025857376,
3.64313779076,
3.23169682276,
3.57450519876,
3.4636351467599997,
3.20130685976,
3.75126047776,
3.33514936476
]
},
{
"command": "pacquet@main",
"mean": 3.39521316536,
"stddev": 0.04425891795708926,
"median": 3.38209537926,
"user": 3.1740021799999996,
"system": 2.5632221399999997,
"min": 3.3440624787599997,
"max": 3.4975036517599998,
"times": [
3.39201980476,
3.4330836577599997,
3.36700538876,
3.4975036517599998,
3.3640538307599996,
3.37217095376,
3.4098220707599998,
3.37150262176,
3.40090719476,
3.3440624787599997
]
},
{
"command": "pnpr@HEAD",
"mean": 1.9551663309600003,
"stddev": 0.16723601116034895,
"median": 1.93423967626,
"user": 1.96080918,
"system": 2.18696294,
"min": 1.76018810976,
"max": 2.20368380476,
"times": [
1.9658433477600001,
2.20368380476,
1.90263600476,
1.76018810976,
1.78047407376,
2.15429773876,
2.01943177676,
1.76466434876,
1.8690574907600002,
2.1313866137599997
]
},
{
"command": "pnpr@main",
"mean": 1.57516300626,
"stddev": 0.14651168644218585,
"median": 1.4896947747600002,
"user": 1.12489738,
"system": 1.23661214,
"min": 1.47033672576,
"max": 1.8668571397600002,
"times": [
1.55499176676,
1.8668571397600002,
1.47489252676,
1.6752012047600002,
1.49507718376,
1.47593418776,
1.47033672576,
1.4843123657600001,
1.77991456476,
1.47411239676
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.55538684016,
"stddev": 0.13475650608903142,
"median": 0.63101099006,
"user": 0.72550234,
"system": 0.91110958,
"min": 0.39402759706,
"max": 0.6890471660599999,
"times": [
0.39593583006000005,
0.66315865806,
0.6890471660599999,
0.59961580106,
0.66974452106,
0.66240617906,
0.66541517406,
0.40447996906000006,
0.41003750606000006,
0.39402759706
]
},
{
"command": "pacquet@main",
"mean": 0.39795924646,
"stddev": 0.017989084255018564,
"median": 0.39034990556000004,
"user": 0.5236306399999999,
"system": 0.68248168,
"min": 0.37726085206000004,
"max": 0.43836523206000005,
"times": [
0.43836523206000005,
0.38484503206000004,
0.41304538806,
0.37726085206000004,
0.38900577406000003,
0.39169403706000006,
0.40747854506000003,
0.40273208706,
0.38893651406,
0.38622900306
]
},
{
"command": "pnpr@HEAD",
"mean": 0.30918112386,
"stddev": 0.00722294195417054,
"median": 0.30914852156000006,
"user": 0.20559834000000002,
"system": 0.5350667800000001,
"min": 0.29961809906000003,
"max": 0.32152137706,
"times": [
0.29961809906000003,
0.30242088806,
0.30841157706,
0.31887367806,
0.30987494706,
0.31011184106,
0.31205722506,
0.30842209606000004,
0.32152137706,
0.30049951006000003
]
},
{
"command": "pnpr@main",
"mean": 0.31968686246000005,
"stddev": 0.020439604538790228,
"median": 0.31117276806000005,
"user": 0.22466313999999996,
"system": 0.53280008,
"min": 0.30530585206000005,
"max": 0.37483046606000003,
"times": [
0.30981806006,
0.30530585206000005,
0.31054927006000005,
0.31622068006000004,
0.31026820306,
0.30898232506,
0.37483046606000003,
0.32272838706,
0.32636911506000005,
0.31179626606000005
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.7664274811200003,
"stddev": 0.027342333064995113,
"median": 1.76670922522,
"user": 0.7801713,
"system": 0.77885144,
"min": 1.72188924372,
"max": 1.8077749377199999,
"times": [
1.77627209272,
1.77846642372,
1.8077749377199999,
1.80123196372,
1.73695046772,
1.7480716347199998,
1.72188924372,
1.75714635772,
1.78014059772,
1.75633109172
]
},
{
"command": "pacquet@main",
"mean": 1.7711883053199997,
"stddev": 0.013012967354131039,
"median": 1.7681199427199998,
"user": 0.7814566000000002,
"system": 0.7733718399999999,
"min": 1.75426279872,
"max": 1.78872255872,
"times": [
1.78687947672,
1.7561609027199998,
1.75426279872,
1.7641675857199999,
1.7623909787199998,
1.76871320872,
1.78872255872,
1.76752667672,
1.7745300607199999,
1.78852880572
]
},
{
"command": "pnpr@HEAD",
"mean": 0.31972397822000004,
"stddev": 0.010106348289908532,
"median": 0.31569891372000003,
"user": 0.21325089999999997,
"system": 0.53569584,
"min": 0.30718734772000006,
"max": 0.33807001572000006,
"times": [
0.30881471672000005,
0.32451949872,
0.31406310672000004,
0.33807001572000006,
0.33206159272,
0.32628207872000003,
0.31569911972000003,
0.31569870772,
0.30718734772000006,
0.31484359772000003
]
},
{
"command": "pnpr@main",
"mean": 0.33182974792000003,
"stddev": 0.017970933308273044,
"median": 0.33083217572,
"user": 0.211092,
"system": 0.57854394,
"min": 0.30326552372000004,
"max": 0.35794504672000005,
"times": [
0.32707992372000005,
0.30738150172000006,
0.30326552372000004,
0.34283159372000005,
0.33650908272,
0.35794504672000005,
0.33439202772000004,
0.32569701372000004,
0.35592344172000007,
0.32727232372000004
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.20232214956000005,
"stddev": 0.014845887104653396,
"median": 0.19482015436000003,
"user": 0.1855239333333333,
"system": 0.07442389999999999,
"min": 0.19040137836,
"max": 0.23120091736000004,
"times": [
0.19096948236000003,
0.19040137836,
0.19393262136000003,
0.19499145436000004,
0.19184532236000001,
0.22451477736000003,
0.19430452736000003,
0.19077213236,
0.19482015436000003,
0.22442734136000003,
0.19961132736000003,
0.22230249336000002,
0.19741593536000002,
0.23120091736000004,
0.19332237836000002
]
},
{
"command": "pacquet@main",
"mean": 0.19373494349333334,
"stddev": 0.011328441132919611,
"median": 0.19095082736000002,
"user": 0.18278693333333332,
"system": 0.06412123333333333,
"min": 0.18614801236000003,
"max": 0.23338888636000002,
"times": [
0.19105603436000002,
0.18912785336000001,
0.23338888636000002,
0.19273329536000003,
0.19130568236000003,
0.18899425336000003,
0.18854612336,
0.19805791736000003,
0.19254844936,
0.19419519336000002,
0.18999596836000002,
0.18809965836000003,
0.18614801236000003,
0.19087599736000002,
0.19095082736000002
]
},
{
"command": "pnpr@HEAD",
"mean": 0.09233068671483873,
"stddev": 0.0034338290005929304,
"median": 0.09206862036,
"user": 0.024906535483870968,
"system": 0.009095745161290322,
"min": 0.08458246936000001,
"max": 0.10594956736000001,
"times": [
0.09277214736,
0.09165170936,
0.09511655836,
0.08913590836,
0.09306914336000001,
0.09021548936,
0.09378133736000001,
0.10594956736000001,
0.08458246936000001,
0.08822174636,
0.09478881436,
0.09476175436,
0.09319430936,
0.09047844236000001,
0.09201032136000001,
0.09125611736,
0.09206862036,
0.09219139936000001,
0.09135133636000001,
0.09231703536000001,
0.09684934336,
0.09155382636,
0.09171247336,
0.09078298236,
0.09312350536000001,
0.09154703336,
0.09219155036,
0.09351625136000001,
0.08931913936000001,
0.09358200436,
0.08915895136
]
},
{
"command": "pnpr@main",
"mean": 0.09170605869333334,
"stddev": 0.0020855929561119915,
"median": 0.09194576536000001,
"user": 0.022085499999999997,
"system": 0.011592323333333333,
"min": 0.08786356436000001,
"max": 0.09459030136,
"times": [
0.09300980336,
0.08909274636,
0.08790423036,
0.09171893536,
0.09250574836,
0.09422881636000001,
0.08910036036,
0.09433452436,
0.09436831636000001,
0.09263388936,
0.09459030136,
0.08831064236000001,
0.09200259636000001,
0.09188893436000001,
0.09078183036000001,
0.09289404536000001,
0.09085100036,
0.09124908436000001,
0.08786356436000001,
0.09435340836,
0.08949174436,
0.09348812836,
0.08880877536000001,
0.09216287736,
0.09381900836000001,
0.09220547736000001,
0.09017524336,
0.09409901236000001,
0.09142358136,
0.09182513436
]
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.9930709523222221,
"stddev": 0.17591119869221752,
"median": 0.9796662681,
"user": 0.952015382222222,
"system": 0.16128595999999995,
"min": 0.6823846211000001,
"max": 1.2944455561,
"times": [
0.6823846211000001,
1.2944455561,
0.9983922201000001,
0.9606895371,
1.1846106961,
0.9050316651000001,
1.0470399221,
0.9796662681,
0.8853780851
]
},
{
"command": "pacquet@main",
"mean": 1.1565832292111111,
"stddev": 0.2534224017709868,
"median": 1.2070164510999999,
"user": 1.1020269377777778,
"system": 0.2144801822222222,
"min": 0.7030834181000001,
"max": 1.5532636251,
"times": [
0.7030834181000001,
0.9341095351,
1.0857819611,
1.2070164510999999,
1.2106579010999998,
1.5532636251,
1.3146882181,
1.3763456471,
1.0243023060999998
]
},
{
"command": "pnpm@HEAD",
"mean": 3.405870222877778,
"stddev": 0.09874254899019504,
"median": 3.3945089911,
"user": 5.26316316,
"system": 0.3047744044444444,
"min": 3.2689133041,
"max": 3.5475736750999998,
"times": [
3.2849050961,
3.5475736750999998,
3.4296361611,
3.3945089911,
3.2689133041,
3.4862929131,
3.3361887241,
3.5163699151,
3.3884432260999997
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.4901380683,
"stddev": 0.06616702267811429,
"median": 4.4611363205,
"user": 1.77382222,
"system": 1.3732158799999998,
"min": 4.412749725,
"max": 4.6178328340000006,
"times": [
4.451723695,
4.5209457010000005,
4.6178328340000006,
4.452088559,
4.412749725,
4.470184082,
4.449696058000001,
4.5811301890000005,
4.506432402000001,
4.438597438
]
},
{
"command": "pacquet@main",
"mean": 4.6453310391,
"stddev": 0.19285746033068532,
"median": 4.565004417000001,
"user": 2.0359962200000004,
"system": 1.5091970799999999,
"min": 4.444747078000001,
"max": 4.970706076000001,
"times": [
4.444747078000001,
4.882804307000001,
4.477466373,
4.709370696000001,
4.84495527,
4.531170387,
4.598838447,
4.477924482000001,
4.970706076000001,
4.515327275000001
]
},
{
"command": "pnpr@HEAD",
"mean": 3.5428161155000004,
"stddev": 0.06576812653285712,
"median": 3.520727127,
"user": 1.46400562,
"system": 1.3712959799999997,
"min": 3.470915087,
"max": 3.689783508,
"times": [
3.689783508,
3.495815922,
3.618023025,
3.470915087,
3.5051434649999997,
3.526267596,
3.551320395,
3.5151866579999997,
3.502180274,
3.553525225
]
},
{
"command": "pnpr@main",
"mean": 3.5498708592999995,
"stddev": 0.098059237791688,
"median": 3.5080507744999996,
"user": 1.35617152,
"system": 1.34166618,
"min": 3.476959354,
"max": 3.793966414,
"times": [
3.497857947,
3.5393646089999997,
3.4771790449999997,
3.5024415569999996,
3.499941524,
3.793966414,
3.5617520099999997,
3.5136599919999996,
3.6355861409999997,
3.476959354
]
}
]
} |
|
| Project | pnpm's project |
| Branch | pr/13495 |
| 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,760.19 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 307.19 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 299.62 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 84.58 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,344.04 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,470.92 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 274.49 ms |
Refusing global operations under sudo is a breaking change: provisioning scripts and CI setups that run `sudo pnpm setup` or `sudo pnpm add -g` with SUDO_USER set would stop working on a minor release. Keep the detection in the TypeScript CLI but downgrade it to a warning that names the v12 removal; pacquet (v12) keeps the hard ERR_PNPM_SUDO_NOT_SUPPORTED failure. The warning is emitted after the reporter is initialized, otherwise it would be logged to a bus nobody is subscribed to yet. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
|
Code review by qodo was updated up to the latest commit a205d5e |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 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 `@pnpm11/pnpm/src/main.ts`:
- Line 218: Add a process.stderr fallback sink in the `@pnpm/logger` globalWarn
path so warnings emitted by checkSudo before initReporter() remain visible for
--json and --parseable flows, while preserving the existing bole warning
behavior when a reporter is configured. Add an integration test covering
checkSudo invocation in both parseable output modes and verify the warning is
written to stderr.
🪄 Autofix
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: 059d8849-f470-4282-8ba6-a33661fe97c9
📒 Files selected for processing (6)
.changeset/refuse-sudo-global.md.changeset/warn-sudo-global.mdpnpm/crates/cli/src/cli_args/sudo_guard.rspnpm11/pnpm/src/checkSudo.test.tspnpm11/pnpm/src/checkSudo.tspnpm11/pnpm/src/main.ts
💤 Files with no reviewable changes (1)
- .changeset/refuse-sudo-global.md
🚧 Files skipped from review as they are similar to previous changes (2)
- pnpm11/pnpm/src/checkSudo.test.ts
- pnpm/crates/cli/src/cli_args/sudo_guard.rs
With --json or --parseable, main() never calls initReporter(), so a globalWarn() goes into a log stream nobody reads and the deprecation notice is lost. Fall back to console.warn(formatWarn(...)) in that case, the way getConfig() already prints its pre-reporter warnings. stdout stays machine-parseable either way. loglevel=silent still suppresses the warning, since that path does initialize a reporter. Drop the checkSudo doc comment: it restated the warning text.
|
Code review by qodo was updated up to the latest commit 9bd7bee |
PR Code Suggestions ✨Warning
No code suggestions found for the PR. |
Summary
Flags commands that write to home-directory locations when pnpm is executed through
sudo. When the effective uid is 0 andSUDO_USERnames a non-root user,pnpm setup,pnpm self-update, and global writes (add,remove,update,runtime,approve-builds, barelink,config set/config deleteresolving to the global scope) are detected — with a hint explaining that pnpm's globals live in the invoking user's home directory and how to opt out for genuine root use (sudo env -u SUDO_USER pnpm ...).The two stacks deliberately differ in severity, because refusing these commands is a breaking change:
becomesteps, and CI bootstraps that runsudo pnpm setuporsudo pnpm add -gkeep working through the v11 line.ERR_PNPM_SUDO_NOT_SUPPORTED.Read-only global commands (
bin -g,root -g,list -g,config get -g, ...) are untouched in both stacks, and plain root sessions withoutSUDO_USER(containers, CI) are unaffected — the guard keys onSUDO_USERprecisely so that root-by-design environments never see it.This is the alternative direction to #13096, which resolved
SUDO_USER's home and redirected all home-derived paths there. That approach writes root-owned files into the invoking user's home (there is noSUDO_UIDchown), overrides explicitsudo -H/sudo -iintent, and diverges from where the ecosystem settled: npm 9 deleted itsSUDO_UIDchown machinery (npm/cli#5710) and tells users not to use sudo, and Homebrew refuses root outright. Telling the user plainly is the honest behavior —sudo pnpm install -gis an npm-prefix habit that has no meaningful interpretation for pnpm.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).
Summary by CodeRabbit
sudousage on Unix systems and warns or blocks commands that modify global state, including setup, self-update, global installs, and global configuration changes.ERR_PNPM_SUDO_NOT_SUPPORTEDerror code.sudo.