Repository navigation
fix(provider-core): npm provider updates into a prefix the server can't write stay manual (carry upstream #30302) - #525
Draft
scuttletoby wants to merge 3 commits into
Draft
scuttletoby wants to merge 3 commits into
scuttletoby wants to merge 3 commits into
Conversation
…'t write stay manual Carried from upstream PR 30302 (open, fixes upstream issue 30281), which conflicts with upstream main as it stands. When a provider CLI was installed with `sudo npm install -g` into a root-owned prefix, T3 offered a one-click Update that ran `npm install -g --prefix <prefix> ...` unprivileged and always failed with EACCES. Before offering the npm-global update, the resolver now checks that the server can write the package's parent directory and `<prefix>/bin`, the two places npm's reify renames in. When either is definitely denied, the install is manual-only: no Update, not in Update all, and `sudo npm install -g --prefix <prefix> --allow-scripts=<pkg> <pkg>@latest` is shown to copy. A missing directory or any other error keeps the one-click update, and Windows is skipped (its access() ignores directory ACLs). Conflict resolution: since the PR was opened, main's npm-global branch gained its own `npm outdated -g --prefix` version lookup and a latestVersionCacheKey. The manual-only result keeps both, instead of the PR's switch to the configured `npm view` lookup, and the PR's test now expects the `npm outdated` probe. The resolver code and tests are otherwise as in the PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Drop this line when upstream merges that PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scuttletoby
marked this pull request as draft
November 19, 2026 12:46
Owner
Author
|
Parked (draft), like #43: the carry adds 116 lines to two upstream files with no seam entry, which goes against thin add-ons. The machine that hit the problem now installs provider CLIs into a user-owned prefix, so the update works there without this change. When upstream merges its PR 30302, the nightly follow brings it in with no seam needed; close this PR then. |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Carries upstream PR pingdotgg#30302 (open,
CONFLICTINGupstream; fixes upstream issue pingdotgg#30281) onto fork main.Problem
A provider CLI installed with
sudo npm install -gsits in a root-owned npm prefix (/usr/localon macOS,/usror/usr/localon Linux). T3 still offered a one-click Update, which runsnpm install -g --prefix <prefix> ...as the server's user. That always fails withEACCESon npm's first rename, and the popover shows only npm's last log line.What the carry does (upstream's change)
Before it offers the npm-global update, the maintenance resolver checks whether the server can write the two directories npm's reify renames in: the package's parent (the scope directory for a scoped package) and
<prefix>/bin. If either is definitely denied (EACCES), the install becomes manual-only, the same as Chocolatey or MacPorts installs: no Update, left out of Update all, and the advisory showsVersion X is out. T3 Code runs <path>; update it with the app or tool that installed it.withsudo npm install -g --prefix <prefix> --allow-scripts=<pkg> <pkg>@latestto copy. A missing directory or any other error keeps today's one-click update. Windows is skipped, because itsaccess()ignores directory ACLs. The resolver is shared, so every npm-managed provider gets this.Conflict resolution
Since upstream opened pingdotgg#30302, main's npm-global branch gained its own
npm outdated -g --prefixversion lookup (upstream pingdotgg#24062) and alatestVersionCacheKey. The PR switched the manual result to the genericnpm viewlookup. The carry keeps main's lookup and cache key on the manual result instead, and the PR's test now expects thenpm outdatedprobe rather thannpm view. Apart from that, the resolver code and both tests are exactly as in pingdotgg#30302. Julius Marminge (the upstream author) is the commit author.The second commit adds the
FORK_CHANGES.mdline. Drop that line, and this carry, when upstream merges pingdotgg#30302: the nightly follow brings in the upstream commit, and its conflict is in this one hunk.Verification
packages/provider-core/src/server/maintenanceResolver.test.ts: the 2 new cases (...when the package scope is read-only,...when the prefix bin is read-only) fail on main (expected { …(5) } to be null) and pass with the fix. The file passes in full (122 tests). They skip as root and on Windows, where directory modes do not stop writes.vp run check:changed: passed.Writable user prefix still offers the update: existing case,
npm install -g --prefix <tmp> ...with nosudo.Real npm (11.x, Linux): a real
npm install -g --prefix <tmp>of a scoped package, with@scopeandbinset to555, fails on a re-install withEACCES/syscall rename. The resolver on that prefix gives:555(read-only)npm install -g --prefix <tmp> ...sudo npm install -g --prefix <tmp> --allow-scripts=@example/package-tool @example/package-tool@latest755(user-owned)npm install -g --prefix <tmp> ...macOS: the same path with the host platform set to
darwingives the same manual result as Linux. The check is plain POSIXaccess(W_OK), so nothing in it is specific to macOS. I have not run it on a real Mac.Windows:
context.platform !== "win32"returns before anyaccess()call, so the Windows result is unchanged by construction. A simulatedwin32run on Linux gave identical output on main and with the fix, but that layout does not reach the npm branch, so it is weak evidence.State question
sudoorchowns the prefix gets one-click updates back on the next refresh. Manual and one-click results share the same version cache key, because the lookup is the same.binmissing, the check reads it as writable (npm creates it), as upstream intends.canUpdate/updateCommandadvisory fields. An empty or partial prefix (directories missing) is treated as writable, which is today's behaviour.EROFS) is notPermissionDenied, so it still offers the one-click update. An unscoped package whose own directory is root-owned inside a user-ownedlib/node_modulesis not checked (only the parent is). Thesudocommand runs root's npm fromsecure_path, which may differ from a version manager's npm.Upstream fit
This is upstream's own open PR, unchanged except for the conflict hunk above. It needs no fork setting and touches no fork seam. If upstream rebases pingdotgg#30302 differently, take their version and drop this.
General vs project
All general: upstream's fix, plus one
FORK_CHANGES.mdline. No host, machine, path or person is named.Claude Opus 5.5 (claude-opus-5-5) in Claude Code.
🤖 Generated with Claude Code