Repository navigation
fix(global): switch global installs over atomically - #13633
Conversation
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains; the previously reported cleanup, enumeration-error, failed-bin-removal, and committed-backup-cleanup paths are addressed at the current head. Reviews (11): Last reviewed commit: "test(global): cover replacing a group wi..." | Re-trigger Greptile |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughGlobal add and update now publish replacement installations transactionally. Existing bins and hash links are restored when publication fails. Replaced installations are cleaned up only after successful publication. Windows shim removal now reports all deletion failures. ChangesGlobal publication flow
Estimated code review effort: 5 (Critical) | ~120 minutes Sequence Diagram(s)sequenceDiagram
participant GlobalCommand
participant GlobalPublication
participant BinDirectory
participant HashLink
participant Cleanup
GlobalCommand->>GlobalPublication: publish replacement installation
GlobalPublication->>BinDirectory: back up and replace bin slots
GlobalPublication->>HashLink: publish new hash link
GlobalPublication-->>GlobalCommand: return published bins
GlobalCommand->>Cleanup: remove replaced groups
Cleanup->>BinDirectory: remove obsolete unprotected bins
Cleanup->>HashLink: remove stale hash links
Possibly related PRs
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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #13633 +/- ##
==========================================
- Coverage 88.21% 88.19% -0.02%
==========================================
Files 624 625 +1
Lines 101592 102311 +719
==========================================
+ Hits 89623 90237 +614
- Misses 11969 12074 +105 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (5)
pnpm/crates/cli/src/cli_args/global/publication.rs (1)
413-418: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueSimplify
io_error_reportand drop the unreachable panic path.The function round-trips through
Resultonly to reachIntoDiagnostic, then adds anunreachable!arm that cannot execute.unwrap_errexpresses the same intent without the extra arm.♻️ Proposed simplification
fn io_error_report(error: io::Error, context: String) -> miette::Report { - match Err::<(), _>(error).into_diagnostic().wrap_err(context) { - Err(report) => report, - Ok(()) => unreachable!("an explicitly constructed error cannot become Ok"), - } + Err::<(), _>(error).into_diagnostic().wrap_err(context).unwrap_err() }🤖 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/global/publication.rs` around lines 413 - 418, Update io_error_report to extract the diagnostic report with unwrap_err() after applying into_diagnostic().wrap_err(context), removing the match expression and unreachable! panic arm while preserving the existing error context.pnpm/crates/cli/src/cli_args/global.rs (1)
480-526: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winConsider making
remove_groupdelegate to this function.
remove_groupat lines 564-580 now duplicates the same three cleanup steps: bin removal with a protected-name filter, hash-link removal, andis_subdir-guarded install-dir removal. Two differences can cause divergent behavior:
remove_groupdiscards every error withlet _ =, so a failed removal is invisible.remove_groupusesfs::remove_fileon the hash link, while this function usesremove_symlink_dir. On Windows,remove_filefails on a directory symlink.Confirm the remaining callers of
remove_groupand whether they can usecleanup_replaced_global_installswith an emptypublished_binsset.#!/bin/bash # Find callers of remove_group and compare with the new cleanup function. rg -nP -C6 '\bremove_group\s*\(' --type=rust # Inspect remove_symlink_dir semantics for hash links. ast-grep run --pattern 'pub fn remove_symlink_dir($$$) { $$$ }' --lang rust pnpm/crates🤖 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/global.rs` around lines 480 - 526, Update remove_group to reuse cleanup_replaced_global_installs instead of duplicating bin, hash-link, and install-directory cleanup. Inspect all remove_group callers and pass an empty published_bins set where their cleanup semantics allow, while preserving protected-bin handling and the active hash. Propagate the helper’s diagnostics and use remove_symlink_dir so hash-link removal works on Windows; retain or adjust callers only where their required behavior differs.pnpm11/global/commands/test/globalPublication.test.ts (2)
125-125: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for the unsupported bin slot type.
backupBinSlotinpnpm11/global/commands/src/globalPublication.tsthrowsGLOBAL_BIN_UNSUPPORTED_TYPEwhen a bin slot is neither a regular file nor a symlink. No test in this file reaches that branch. The review guide requires tests that prove unsupported link types, so this branch and its cleanup behavior are unverified.Seed a directory at a bin slot name that the manifest declares, then assert
publishGlobalInstallrejects withERR_PNPM_GLOBAL_BIN_UNSUPPORTED_TYPE, that the fresh install directory is removed, and that no backup directory remains.As per path instructions, REVIEW_GUIDE.md states: "Tests must prove failure rollback, cleanup ordering, error aggregation, unsupported link types, and Windows behavior with meaningful cross-platform coverage."
🤖 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 `@pnpm11/global/commands/test/globalPublication.test.ts` at line 125, Add a test in the global publication test suite that creates a directory at a manifest-declared bin slot, then verifies publishGlobalInstall rejects with ERR_PNPM_GLOBAL_BIN_UNSUPPORTED_TYPE, removes the fresh install directory, and leaves no backup directory. Exercise the backupBinSlot unsupported-type branch while preserving the existing rollback assertions.Source: Path instructions
500-508: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueExtract the cleanup fixture setup.
The three cleanup tests repeat the same setup:
fs.mkdtemp, assigntestRoot, deriveglobalDirandglobalBinDir, thenmkdirthe directories. A smallcreateCleanupFixture()helper alongsidecreateFixturewould remove the repetition and keep each test focused on the behavior it asserts.Also applies to: 531-542, 563-572
🤖 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 `@pnpm11/global/commands/test/globalPublication.test.ts` around lines 500 - 508, Extract the repeated temporary-directory setup from the three cleanup tests into a shared createCleanupFixture helper alongside createFixture. Have it create and assign testRoot, derive globalDir and globalBinDir, create the required directories including old-install, and return the fixture values needed by each test; replace the duplicated setup in all three cleanup tests while preserving their existing behavior.pnpm11/global/commands/src/globalPublication.ts (1)
77-97: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick winConsider aggregating cleanup failures so cleanup completes.
Publication already succeeded when
cleanupReplacedGlobalInstallsruns. A singleremoveBinrejection at Line 89 aborts the remaining work: the other stale bins, the stale hash link, and the replaced install directory all stay on disk, and later groups are never cleaned.Promise.allSettledover the bin removals, plus an aggregated error per group, would leave less residue after a partial failure.This is optional for this PR. The prior code had the same sequential abort behavior.
🤖 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 `@pnpm11/global/commands/src/globalPublication.ts` around lines 77 - 97, Update cleanupReplacedGlobalInstall to aggregate failures from all bin removals rather than aborting on the first removeBin rejection, while preserving sequential removal if required. Ensure stale hash-link and install-directory cleanup still runs, and throw an aggregated error for the group after all cleanup attempts complete so later groups can continue.
🤖 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/global.rs`:
- Around line 247-263: Update the error-context strings on the
`publish_global_install` and `cleanup_replaced_global_installs` calls in the
global install replacement path to match the established wording used by the
corresponding add path. Replace the outdated publish context with the shared
term describing bin/hash-link publishing, and use the add path’s cleanup
terminology for the cleanup call.
In `@pnpm11/global/commands/src/globalPublication.ts`:
- Around line 197-200: Update getSymlinkType to tolerate a missing symlink
target on Windows: handle the ENOENT rejection from fs.promises.stat(link) by
returning 'file', while preserving directory detection and non-Windows undefined
behavior. Add coverage to the Windows publication test setup that creates a
dangling symlink in globalBinDir and verifies publication succeeds.
---
Nitpick comments:
In `@pnpm/crates/cli/src/cli_args/global.rs`:
- Around line 480-526: Update remove_group to reuse
cleanup_replaced_global_installs instead of duplicating bin, hash-link, and
install-directory cleanup. Inspect all remove_group callers and pass an empty
published_bins set where their cleanup semantics allow, while preserving
protected-bin handling and the active hash. Propagate the helper’s diagnostics
and use remove_symlink_dir so hash-link removal works on Windows; retain or
adjust callers only where their required behavior differs.
In `@pnpm/crates/cli/src/cli_args/global/publication.rs`:
- Around line 413-418: Update io_error_report to extract the diagnostic report
with unwrap_err() after applying into_diagnostic().wrap_err(context), removing
the match expression and unreachable! panic arm while preserving the existing
error context.
In `@pnpm11/global/commands/src/globalPublication.ts`:
- Around line 77-97: Update cleanupReplacedGlobalInstall to aggregate failures
from all bin removals rather than aborting on the first removeBin rejection,
while preserving sequential removal if required. Ensure stale hash-link and
install-directory cleanup still runs, and throw an aggregated error for the
group after all cleanup attempts complete so later groups can continue.
In `@pnpm11/global/commands/test/globalPublication.test.ts`:
- Line 125: Add a test in the global publication test suite that creates a
directory at a manifest-declared bin slot, then verifies publishGlobalInstall
rejects with ERR_PNPM_GLOBAL_BIN_UNSUPPORTED_TYPE, removes the fresh install
directory, and leaves no backup directory. Exercise the backupBinSlot
unsupported-type branch while preserving the existing rollback assertions.
- Around line 500-508: Extract the repeated temporary-directory setup from the
three cleanup tests into a shared createCleanupFixture helper alongside
createFixture. Have it create and assign testRoot, derive globalDir and
globalBinDir, create the required directories including old-install, and return
the fixture values needed by each test; replace the duplicated setup in all
three cleanup tests while preserving their existing behavior.
🪄 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: 48fe51f1-5694-4d8f-b050-2162df295b4b
📒 Files selected for processing (12)
.changeset/safe-global-bin-publication.mdpnpm/crates/cli/src/cli_args/global.rspnpm/crates/cli/src/cli_args/global/publication.rspnpm/crates/cli/src/cli_args/global/publication/tests.rspnpm11/bins/remover/src/removeBins.tspnpm11/global/commands/src/globalAdd.tspnpm11/global/commands/src/globalPublication.tspnpm11/global/commands/src/globalUpdate.tspnpm11/global/commands/test/globalAdd.test.tspnpm11/global/commands/test/globalPublication.test.tspnpm11/global/commands/test/globalUpdate.test.tspnpm11/global/commands/test/removeBinWindows.test.ts
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.4881775909200003,
"stddev": 0.12114503467970668,
"median": 2.44901310432,
"user": 1.78737332,
"system": 1.4432537799999998,
"min": 2.3747655238200003,
"max": 2.77654330482,
"times": [
2.45126863582,
2.44675757282,
2.50514246482,
2.77654330482,
2.40253090682,
2.61628758882,
2.4216390918200004,
2.42728057282,
2.3747655238200003,
2.45956024682
]
},
{
"command": "pacquet@main",
"mean": 2.5816975149200005,
"stddev": 0.1684211294455156,
"median": 2.57534119482,
"user": 1.7350085199999998,
"system": 1.37406358,
"min": 2.37273930382,
"max": 2.81257547582,
"times": [
2.46072408782,
2.76931672682,
2.6711537738200004,
2.64641124282,
2.5042711468200003,
2.75668380382,
2.81257547582,
2.38170386082,
2.44139572682,
2.37273930382
]
},
{
"command": "pnpr@HEAD",
"mean": 1.6079985242200003,
"stddev": 0.14493009669503823,
"median": 1.62355701082,
"user": 1.1653313199999995,
"system": 1.1812077799999998,
"min": 1.39941220182,
"max": 1.7903083598199998,
"times": [
1.73786629082,
1.67701106482,
1.7903083598199998,
1.6027009968200001,
1.40158972182,
1.4674274698199998,
1.64441302482,
1.77097526282,
1.39941220182,
1.58828084882
]
},
{
"command": "pnpr@main",
"mean": 1.55228666972,
"stddev": 0.12372826287672922,
"median": 1.59322159782,
"user": 1.1610708199999995,
"system": 1.26431098,
"min": 1.39573143182,
"max": 1.69842017082,
"times": [
1.42974909482,
1.64242778682,
1.43682966482,
1.68586065782,
1.5774905318199999,
1.65043040182,
1.60895266382,
1.39697429282,
1.39573143182,
1.69842017082
]
}
]
}Scenario: Isolated linker: fresh restore, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.2686767979200001,
"stddev": 0.005448302096683166,
"median": 0.26913015862000006,
"user": 0.24175909999999998,
"system": 0.5496346599999999,
"min": 0.26126673462000005,
"max": 0.28058003462000003,
"times": [
0.26644136662000006,
0.26883143562000006,
0.27178550662000006,
0.28058003462000003,
0.26942888162000006,
0.26986825762000005,
0.27073693362000006,
0.26537810462000005,
0.26245072362000005,
0.26126673462000005
]
},
{
"command": "pacquet@main",
"mean": 0.27572824772000004,
"stddev": 0.017700252682407915,
"median": 0.27154717912000004,
"user": 0.2450253,
"system": 0.55505416,
"min": 0.25656022462000005,
"max": 0.30716534562000003,
"times": [
0.26297037262000006,
0.27898130462000004,
0.28733331862000006,
0.30716534562000003,
0.29919989962000004,
0.26411305362000004,
0.25871409862000005,
0.26280908862,
0.27943577062,
0.25656022462000005
]
},
{
"command": "pnpr@HEAD",
"mean": 0.27716678362,
"stddev": 0.007772460990721254,
"median": 0.27873514162,
"user": 0.23947729999999998,
"system": 0.53181036,
"min": 0.26185969062000003,
"max": 0.28521717462000007,
"times": [
0.27625494262000005,
0.28037044962,
0.28490642862000004,
0.28178667662000006,
0.28521717462000007,
0.28374250862000006,
0.26185969062000003,
0.26773045262000006,
0.27709983362000007,
0.27269967862000005
]
},
{
"command": "pnpr@main",
"mean": 0.28183716852,
"stddev": 0.006494325281211835,
"median": 0.28088949762000004,
"user": 0.2395229,
"system": 0.5477593599999999,
"min": 0.27504173862000003,
"max": 0.29780344062,
"times": [
0.28054017962000005,
0.27870776062,
0.27504173862000003,
0.27763700362000004,
0.29780344062,
0.28283336662,
0.28123881562,
0.28134761962000004,
0.27672839262000004,
0.28649336762000005
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + cold store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 2.6379855700799997,
"stddev": 0.06719483834090817,
"median": 2.61870058788,
"user": 1.60798636,
"system": 1.4253223199999998,
"min": 2.6028303188799997,
"max": 2.8275159238799996,
"times": [
2.62366011488,
2.8275159238799996,
2.60627924988,
2.62490263088,
2.63173897888,
2.6028303188799997,
2.61442851788,
2.6110987898799998,
2.61443897688,
2.62296219888
]
},
{
"command": "pacquet@main",
"mean": 2.62679201278,
"stddev": 0.02450039515527258,
"median": 2.63585967838,
"user": 1.65718016,
"system": 1.3981140200000002,
"min": 2.58307210188,
"max": 2.66459930088,
"times": [
2.58307210188,
2.6359225408799998,
2.63579681588,
2.6226001698799997,
2.59465218288,
2.63852773588,
2.63644814088,
2.66459930088,
2.64564271088,
2.61065842788
]
},
{
"command": "pnpr@HEAD",
"mean": 1.60252624578,
"stddev": 0.11704865498233026,
"median": 1.5757510833800001,
"user": 1.12201316,
"system": 1.17722682,
"min": 1.46431617288,
"max": 1.8555783658800002,
"times": [
1.5102595468800002,
1.56313839588,
1.46431617288,
1.6017380058800001,
1.62959864088,
1.53816826188,
1.5883637708800002,
1.74344992488,
1.5306513718800001,
1.8555783658800002
]
},
{
"command": "pnpr@main",
"mean": 1.6814983435800002,
"stddev": 0.14077556188373264,
"median": 1.6899775483800001,
"user": 1.11479536,
"system": 1.31297972,
"min": 1.4495586528800002,
"max": 1.8878003808800001,
"times": [
1.6714292128800001,
1.4495586528800002,
1.85978532488,
1.74706701388,
1.74668831088,
1.7085258838800002,
1.50152797988,
1.8878003808800001,
1.6457874948800002,
1.5968131808800001
]
}
]
}Scenario: Isolated linker: fresh install, hot cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.42346397456000007,
"stddev": 0.024630184802442782,
"median": 0.41718822236,
"user": 0.5594263799999999,
"system": 0.70462752,
"min": 0.39664162586,
"max": 0.47013496186000003,
"times": [
0.41170199886000003,
0.39841548486,
0.44247489286,
0.39664162586,
0.43379394886,
0.40796247786,
0.42267444586,
0.44865493686,
0.40218497186,
0.47013496186000003
]
},
{
"command": "pacquet@main",
"mean": 0.4552728180600001,
"stddev": 0.06653793021372034,
"median": 0.43506105936,
"user": 0.6375326799999999,
"system": 0.7297282199999999,
"min": 0.41042136586,
"max": 0.63865158186,
"times": [
0.63865158186,
0.41042136586,
0.43562950886,
0.42537978886,
0.44230541486,
0.42271565486,
0.47452126886,
0.43722859986,
0.43449260986,
0.43138238686
]
},
{
"command": "pnpr@HEAD",
"mean": 0.30930997705999996,
"stddev": 0.0068382358391130185,
"median": 0.30986183485999996,
"user": 0.21149788000000003,
"system": 0.52843342,
"min": 0.30131304986,
"max": 0.32062304386,
"times": [
0.30131304986,
0.31016461986,
0.31040112386,
0.31387698686,
0.30955904986,
0.32062304386,
0.30282897386,
0.30152591986,
0.30452179986,
0.31828520286
]
},
{
"command": "pnpr@main",
"mean": 0.32795755696,
"stddev": 0.012025574371997541,
"median": 0.32572373336,
"user": 0.22202848,
"system": 0.5615186200000001,
"min": 0.31054126886,
"max": 0.34454258386000003,
"times": [
0.31829960986,
0.32584798686,
0.31359176986,
0.31054126886,
0.32559947986,
0.34193840086,
0.34454258386000003,
0.33808499986,
0.33770102586,
0.32342844386
]
}
]
}Scenario: Isolated linker: fresh install, cold cache + hot store
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 1.76135616726,
"stddev": 0.03580127543846231,
"median": 1.75147622216,
"user": 0.86842902,
"system": 0.78724184,
"min": 1.72553802216,
"max": 1.83287133916,
"times": [
1.83287133916,
1.79797018016,
1.76166861916,
1.73679630716,
1.79428171516,
1.72885023716,
1.74739167216,
1.72553802216,
1.75556077216,
1.73263280816
]
},
{
"command": "pacquet@main",
"mean": 1.76612545906,
"stddev": 0.04023340064538459,
"median": 1.75422209816,
"user": 0.8499429199999999,
"system": 0.8354431400000001,
"min": 1.72201279516,
"max": 1.84378013116,
"times": [
1.75440883216,
1.73167839116,
1.77405434416,
1.74311249716,
1.84378013116,
1.8233323971600002,
1.78093207616,
1.75403536416,
1.7339077621599999,
1.72201279516
]
},
{
"command": "pnpr@HEAD",
"mean": 0.31625763486,
"stddev": 0.01852191980910362,
"median": 0.31339833015999996,
"user": 0.22451012,
"system": 0.5252052400000001,
"min": 0.29227768515999997,
"max": 0.35199867516,
"times": [
0.35199867516,
0.33197276416,
0.30924446816,
0.31251655516,
0.31428010516,
0.29404076215999997,
0.29227768515999997,
0.30441408616,
0.31882249316,
0.33300875416
]
},
{
"command": "pnpr@main",
"mean": 0.32429858176000004,
"stddev": 0.005949549128433733,
"median": 0.32457394916000004,
"user": 0.22876462000000003,
"system": 0.5519426399999999,
"min": 0.31602366616,
"max": 0.33657076716,
"times": [
0.32760692716,
0.32506156716,
0.32005525415999997,
0.33657076716,
0.31602366616,
0.32046937416,
0.32408633116,
0.32885077816,
0.32567525216,
0.31858590016
]
}
]
}Scenario: Isolated linker: fresh resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.21415335276461536,
"stddev": 0.015520477377543944,
"median": 0.20831829338000002,
"user": 0.18246351230769225,
"system": 0.06624001384615384,
"min": 0.19538333438000002,
"max": 0.24698411138,
"times": [
0.21778669938,
0.19538333438000002,
0.19598379438000002,
0.22829314738,
0.20440170038000002,
0.22581223738,
0.20831829338000002,
0.23229027138000002,
0.24698411138,
0.20028489238000002,
0.20608805738000002,
0.21608961438000002,
0.20627743238000001
]
},
{
"command": "pacquet@main",
"mean": 0.22663927513,
"stddev": 0.01859534023954589,
"median": 0.22322711538,
"user": 0.17966140333333333,
"system": 0.06322619333333333,
"min": 0.20377502238,
"max": 0.25307893538000004,
"times": [
0.23583104838000002,
0.20505901938,
0.22896584338,
0.21020327338,
0.20905874738000002,
0.24604993338,
0.21748838738,
0.21613020038,
0.25307893538000004,
0.25179393538,
0.20377502238,
0.24223695538
]
},
{
"command": "pnpr@HEAD",
"mean": 0.08892500573483869,
"stddev": 0.0026056914025045824,
"median": 0.08822706438,
"user": 0.021085271612903227,
"system": 0.010870606451612906,
"min": 0.08514119538,
"max": 0.09495697338,
"times": [
0.08991640438000001,
0.09235980438000001,
0.09495697338,
0.09110835838,
0.08541210538,
0.08815195338000001,
0.08708451338,
0.08728609338,
0.08649245038,
0.08775257238,
0.08822706438,
0.08590038538,
0.08808627038,
0.08619654138,
0.08952661038,
0.09153101538,
0.09092539438,
0.09191070938,
0.08697621038,
0.08533292638000001,
0.08946931438,
0.08539689638,
0.08965237738000001,
0.09375702538,
0.09008529238,
0.09128932038,
0.08514119538,
0.08801615738,
0.08722868438,
0.09018510138000001,
0.09131945638
]
},
{
"command": "pnpr@main",
"mean": 0.09016035221870967,
"stddev": 0.004073518984638894,
"median": 0.08833289438,
"user": 0.021772110322580647,
"system": 0.011225154838709674,
"min": 0.08580902238,
"max": 0.10158512138,
"times": [
0.09117254938000001,
0.08695638238,
0.08615273038,
0.08770293838,
0.09058028438,
0.09615872538,
0.09418432938,
0.09402663238,
0.10158512138,
0.10037455138000001,
0.08864639438000001,
0.08612068938,
0.08745302738,
0.08745493138,
0.08833289438,
0.08808633938,
0.08580902238,
0.08634990238000001,
0.08735761838,
0.08776302038,
0.08628721338,
0.09247328838,
0.09499461538000001,
0.09073356338,
0.09215396738000001,
0.09202373138,
0.09134387038,
0.08776050738,
0.09018646538,
0.08713886438,
0.08760674738
]
}
]
}Scenario: Isolated linker: peer-heavy resolve, hot cache, offline
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 0.85135448164,
"stddev": 0.1286787690933821,
"median": 0.77851180864,
"user": 0.8219187133333333,
"system": 0.12881348444444443,
"min": 0.71629708664,
"max": 1.07311385164,
"times": [
1.0183278126400002,
1.07311385164,
0.7641158706400001,
0.8941285076400001,
0.90891745664,
0.77851180864,
0.71629708664,
0.74206766664,
0.76671027364
]
},
{
"command": "pacquet@main",
"mean": 0.9289498015288891,
"stddev": 0.31519176811011645,
"median": 0.73981806264,
"user": 0.9046259355555555,
"system": 0.15939748444444443,
"min": 0.6309098026400001,
"max": 1.4753555466400001,
"times": [
1.3560621376400002,
0.73981806264,
0.6309098026400001,
0.7288012636400001,
1.1651669636400002,
0.79434894164,
0.73295750664,
0.7371279886400001,
1.4753555466400001
]
},
{
"command": "pnpm@HEAD",
"mean": 3.347888693973333,
"stddev": 0.15955091326700566,
"median": 3.41529113664,
"user": 5.073586935555555,
"system": 0.33156959555555554,
"min": 3.0968468436400003,
"max": 3.5355394966400002,
"times": [
3.49497735964,
3.36012935864,
3.0968468436400003,
3.14130998164,
3.41529113664,
3.20815393164,
3.5355394966400002,
3.44800746764,
3.4307426696400003
]
}
]
}Scenario: Isolated linker: fresh restore, cold cache + cold store + cold pnpr
BENCHMARK_REPORT.json{
"results": [
{
"command": "pacquet@HEAD",
"mean": 4.588646603979999,
"stddev": 0.03522066171102139,
"median": 4.590034641179999,
"user": 2.41622014,
"system": 1.7284277799999999,
"min": 4.52474895418,
"max": 4.63299763818,
"times": [
4.53860580918,
4.62603865918,
4.52474895418,
4.63299763818,
4.60693228318,
4.5922522911799994,
4.58190718618,
4.579429783179999,
4.5878169911799995,
4.6157364441799995
]
},
{
"command": "pacquet@main",
"mean": 4.58471577778,
"stddev": 0.11852219447254057,
"median": 4.56618095468,
"user": 2.1992392400000003,
"system": 1.64987798,
"min": 4.494172832179999,
"max": 4.90890005018,
"times": [
4.57429799318,
4.59065958118,
4.55806391618,
4.57701353618,
4.90890005018,
4.523235157179999,
4.57576111718,
4.50484020318,
4.54021339118,
4.494172832179999
]
},
{
"command": "pnpr@HEAD",
"mean": 3.60776951248,
"stddev": 0.1513983761844863,
"median": 3.5570783186800004,
"user": 1.4268682400000001,
"system": 1.4383825799999999,
"min": 3.49130453318,
"max": 3.9874981431800003,
"times": [
3.73490408718,
3.5268217221800002,
3.5550010691800003,
3.50126082518,
3.6015014931800002,
3.9874981431800003,
3.55915556818,
3.5113995511800002,
3.60884813218,
3.49130453318
]
},
{
"command": "pnpr@main",
"mean": 3.6582625495800003,
"stddev": 0.16275781027895603,
"median": 3.59685958568,
"user": 1.4639069399999998,
"system": 1.4932791799999996,
"min": 3.50915347918,
"max": 3.93360827918,
"times": [
3.92768516818,
3.50915347918,
3.57654683318,
3.93360827918,
3.61717233818,
3.53145767518,
3.53765555218,
3.7323767931800003,
3.5127412021800004,
3.7042281751800004
]
}
]
} |
|
| Project | pnpm's project |
| Branch | pr/13633 |
| 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,464.32 ms |
| isolated-linker.fresh-install.cold-cache.hot-store | 📈 view plot | 292.28 ms |
| isolated-linker.fresh-install.hot-cache.hot-store | 📈 view plot | 301.31 ms |
| isolated-linker.fresh-resolve.hot-cache.offline | 📈 view plot | 85.14 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store | 📈 view plot | 1,399.41 ms |
| isolated-linker.fresh-restore.cold-cache.cold-store.cold-pnpr | 📈 view plot | 3,491.30 ms |
| isolated-linker.fresh-restore.hot-cache.hot-store | 📈 view plot | 261.86 ms |
bec87d5 to
0e16e61
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (2)
pnpm11/global/commands/test/globalPublication.test.ts (2)
500-508: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winExtract the duplicated cleanup fixture setup.
Lines 500-508, 531-542, and 563-572 repeat the same scaffold:
mkdtemp, assigntestRoot, deriveglobalDirandglobalBinDir, then create directories. Add acreateCleanupFixturehelper next tocreateFixtureand return the paths. This removes the duplication and keeps the temp-root bookkeeping in one place.The path instructions ask for depth on missed reuse and duplication.
♻️ Proposed helper
interface CleanupFixture { root: string globalDir: string globalBinDir: string } async function createCleanupFixture (): Promise<CleanupFixture> { const root = await fs.mkdtemp(path.join(os.tmpdir(), 'pnpm-global-cleanup-')) testRoot = root const globalDir = path.join(root, 'global') const globalBinDir = path.join(root, 'bin') await Promise.all([ fs.mkdir(globalDir, { recursive: true }), fs.mkdir(globalBinDir, { recursive: true }), ]) return { root, globalDir, globalBinDir } }🤖 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 `@pnpm11/global/commands/test/globalPublication.test.ts` around lines 500 - 508, Add a CleanupFixture type and createCleanupFixture helper beside createFixture to centralize temporary-root creation, testRoot assignment, path derivation, and directory setup. Replace the duplicated setup blocks in all three cleanup tests with this helper and reuse its returned root, globalDir, and globalBinDir paths.Source: Path instructions
51-65: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueReturn only the packages whose bins the mock actually wrote.
When
skipMissingBinSourcesis true, the loop skips a command at Line 52, but Line 65 still returns that command'spkgName. The mock then reports a package as linked when it wrote nothing. The current tests do not depend on this value, so this is a fidelity gap only. Track the written packages to keep the mock aligned with the reallinkBinsOfPackagescontract.♻️ Proposed change to track written packages
+ const writtenPkgNames: string[] = [] for (const { command } of commands) { if (skipMissingBinSources && !existsSync(command.path)) continue const slot = path.join(globalBinDir, command.name) await fs.rm(slot, { force: true, recursive: true }) await fs.copyFile(command.path, slot) const sourceStat = await fs.stat(command.path) await fs.chmod(slot, sourceStat.mode & 0o777) linkedBinNames.push(command.name) + writtenPkgNames.push(command.name) writes++ if (linkFailure != null && writes === linkFailure.afterWrites) { throw linkFailure.error } } /* eslint-enable no-await-in-loop */ - return commands.map(({ pkgName }) => pkgName) + return commands.filter(({ command }) => writtenPkgNames.includes(command.name)).map(({ pkgName }) => pkgName)🤖 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 `@pnpm11/global/commands/test/globalPublication.test.ts` around lines 51 - 65, Update the mock’s loop to track package names only after a bin is successfully written, including the existing skip behavior for missing sources. Return this written-package collection instead of mapping all input commands, while preserving the current bin write and failure-injection flow.
🤖 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/global/commands/test/globalPublication.test.ts`:
- Around line 292-293: Guard the direct symlink creation in the test setup
around the two fs.symlink calls, reusing the existing EPERM handling pattern
from seedSymlinkOrRegularFile. On Windows when symlink creation is unavailable,
apply the established fallback or skip behavior so the test remains valid on
hosts without Developer Mode or elevation.
---
Nitpick comments:
In `@pnpm11/global/commands/test/globalPublication.test.ts`:
- Around line 500-508: Add a CleanupFixture type and createCleanupFixture helper
beside createFixture to centralize temporary-root creation, testRoot assignment,
path derivation, and directory setup. Replace the duplicated setup blocks in all
three cleanup tests with this helper and reuse its returned root, globalDir, and
globalBinDir paths.
- Around line 51-65: Update the mock’s loop to track package names only after a
bin is successfully written, including the existing skip behavior for missing
sources. Return this written-package collection instead of mapping all input
commands, while preserving the current bin write and failure-injection flow.
🪄 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: db01cbfa-b6ae-43be-96a9-55f5b6aa1663
📒 Files selected for processing (12)
.changeset/safe-global-bin-publication.mdpnpm/crates/cli/src/cli_args/global.rspnpm/crates/cli/src/cli_args/global/publication.rspnpm/crates/cli/src/cli_args/global/publication/tests.rspnpm11/bins/remover/src/removeBins.tspnpm11/global/commands/src/globalAdd.tspnpm11/global/commands/src/globalPublication.tspnpm11/global/commands/src/globalUpdate.tspnpm11/global/commands/test/globalAdd.test.tspnpm11/global/commands/test/globalPublication.test.tspnpm11/global/commands/test/globalUpdate.test.tspnpm11/global/commands/test/removeBinWindows.test.ts
🚧 Files skipped from review as they are similar to previous changes (10)
- pnpm11/bins/remover/src/removeBins.ts
- pnpm11/global/commands/src/globalUpdate.ts
- pnpm/crates/cli/src/cli_args/global.rs
- pnpm11/global/commands/src/globalAdd.ts
- pnpm11/global/commands/test/removeBinWindows.test.ts
- pnpm/crates/cli/src/cli_args/global/publication/tests.rs
- .changeset/safe-global-bin-publication.md
- pnpm/crates/cli/src/cli_args/global/publication.rs
- pnpm11/global/commands/test/globalUpdate.test.ts
- pnpm11/global/commands/test/globalAdd.test.ts
PR Code Suggestions ✨Latest suggestions up to f42423f Warning
Previous suggestionsSuggestions up to commit 078a4d0
Suggestions up to commit 3410313
Suggestions up to commit cefde86
Suggestions up to commit eda831e
Suggestions up to commit 8b8cecc
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Code Review by Qodo
1. Comment says used to
|
291e261 to
b877d34
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
pnpm/crates/cli/src/cli_args/global/publication.rs (1)
32-36: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueUse the imported
fsalias.Line 9 already imports
fs. Line 34 qualifies the same function asstd::fs::rename. Usefs::renamefor consistency with the rest of the file.The code style guide asks for merged explicit imports.
♻️ Proposed change
impl FsRename for Host { fn rename(source: &Path, target: &Path) -> io::Result<()> { - std::fs::rename(source, target) + fs::rename(source, target) } }🤖 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/global/publication.rs` around lines 32 - 36, Update `Host::rename` to call the imported `fs::rename` alias instead of qualifying the function through `std::fs`, preserving the existing arguments and return behavior.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/cli/src/cli_args/global/publication.rs`:
- Around line 32-36: Update `Host::rename` to call the imported `fs::rename`
alias instead of qualifying the function through `std::fs`, preserving the
existing arguments and return behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: 53e0dcbf-7333-49f4-9995-c53b39a93b69
📒 Files selected for processing (5)
pnpm/crates/cli/src/cli_args/global.rspnpm/crates/cli/src/cli_args/global/publication.rspnpm/crates/cli/src/cli_args/global/publication/tests.rspnpm11/global/commands/src/globalPublication.tspnpm11/global/commands/test/globalPublication.test.ts
🚧 Files skipped from review as they are similar to previous changes (3)
- pnpm11/global/commands/src/globalPublication.ts
- pnpm/crates/cli/src/cli_args/global/publication/tests.rs
- pnpm/crates/cli/src/cli_args/global.rs
|
Code review by qodo was updated up to the latest commit b877d34 |
|
Code review by qodo was updated up to the latest commit d7a0861 |
Treat backup-directory removal after a committed publication as best-effort in both stacks, so a failed removal no longer reports a successful install as failed. Attempt every stale bin, hash-link, and install-directory removal during cleanup and aggregate the failures instead of aborting at the first error. Tolerate dangling Windows bin symlinks when snapshotting slots so a broken global install can be repaired by re-running the install. Also align the global update error contexts with the add path, simplify io_error_report, and fix dylint findings in the new publication code (trailing commas, a single-letter generic, import collapse). Co-Authored-By: Claude Fable 5 <[email protected]>
Seed test symlinks through a helper that bails out on Windows hosts where symlink creation needs elevation, and make the linker mock report only the packages whose bins it actually wrote. Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
Publication creates its backup directory inside the global bin directory, which the bin linker used to be the first to create. A first global install into a fresh bin directory therefore failed with ENOENT. Also mock cmd-extension in the Windows bin removal test: the real extension is derived from the host COMSPEC and is uppercase on Windows, which made the expected shim paths host-dependent. Co-Authored-By: Claude Fable 5 <[email protected]>
The install directory is the only record of which bins a group owns, so removing it after the enumeration failed would strand those executables on PATH with nothing left to associate them with. Report the failure and leave the group for a later run to clean up. Co-Authored-By: Claude Fable 5 <[email protected]>
d7a0861 to
8b8cecc
Compare
|
Code review by qodo was updated up to the latest commit 8b8cecc |
Bin shims embedded the path of the install directory a particular install produced, so activating a new version meant rewriting every shim in the shared global bin directory: the commands were removed, relinked, and only then was the hash link repointed. Every command was missing from PATH for the duration, even when the install succeeded. Generate the shims from the group's hash link instead, and repoint that link before linking rather than after. The link name is a stable cache key over the group's aliases, so the shim text no longer changes between versions and both linkers' idempotency checks leave the files untouched; activating a new install is then the single rename that repoints the link. Prune the slot of a declared command whose file is missing, which the removal pass used to cover. Co-Authored-By: Claude Fable 5 <[email protected]>
Co-Authored-By: Claude Fable 5 <[email protected]>
The module publishes nothing: it makes a freshly installed group the active one. "Publish" already means uploading a package to a registry in this repo, and the word reached users through the error messages and the release note. Rename the modules, symbols, and messages to activation. The two error codes are unchanged, so the stable contract does not move. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Code review by qodo was updated up to the latest commit cefde86 |
Cleanup aggregates removal failures and carries on, but it then deleted the group's hash link and installation directory anyway. A bin left behind by a failed removal is only discoverable through those manifests, so deleting them stranded it on PATH with nothing left to retry from. Remove every bin the group still owns, then keep the group when any of those removals failed. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Code review by qodo was updated up to the latest commit 3410313 |
A committed activation must not fail because its temporary backup directory could not be removed, but discarding the error hid a real filesystem problem and let backup directories accumulate under the global bin directory unnoticed. Report the failure on the global log channel instead. The TypeScript CLI warns through globalWarn; the Rust CLI returns the leftover from the activation so the command handler, which holds the reporter, emits the same message on pnpm:global. Co-Authored-By: Claude Fable 5 <[email protected]>
|
Code review by qodo was updated up to the latest commit 078a4d0 |
Changing a group's packages changes its hash, so its commands are rewritten to point at the new hash link and the old one is unlinked. Every cleanup test so far used a group whose hash matched the active one, leaving that combination untested: a command shared with the group that just took over must survive the unlinking that removes the old hash link and installation directory. Verified both tests fail when the activated-bin guard is removed. Co-Authored-By: Claude Fable 5 <[email protected]>
Dismissed because a newer commit was pushed; Greptile will re-review the current head.
|
Code review by qodo was updated up to the latest commit f42423f |
Summary
Activating a global install used to rewrite every command shim in the shared global bin directory. The shims embedded the path of the directory a particular install produced, so switching versions meant removing all of the commands, relinking them, and only then moving the hash link. Every command was missing from
PATHfor the duration — on success as much as on failure — and a linker or hash-link failure could leave the previous global package unusable.Verified end to end: across
pnpm add -gof a new version, the shim keeps the same inode and mtime while the command goes from the old version to the new one.Squash Commit Body
Checklist
pnpm/port.pnpm changeset) for the affected published packages and CLIs.Written by an agent (Codex, GPT-5), reshaped by an agent (Claude Code, claude-fable-5).
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.Summary by CodeRabbit
Bug Fixes
Tests