Skip to content

Run npm update -g in a scratch HOME and TMPDIR - #2224

Merged
Sanne merged 1 commit into
Sanne:mainfrom
Sanne-ai-bot:issue-2221-opencode-update-home
Nov 13, 2026
Merged

Sanne merged 1 commit into
Sanne:mainfrom
Sanne-ai-bot:issue-2221-opencode-update-home

Conversation

@Sanne-ai-bot

Copy link
Copy Markdown
Collaborator

Closes #2221

What

isx update-all and isx project update run npm update -g with a scratch HOME and TMPDIR, keeping root's npm cache and npmrc, so install scripts (opencode's postinstall) no longer leave root-owned directories in /root that branches inherit.

Design

Chosen: wrap the update in a script (NpmGlobalInstall.UPDATE_SCRIPT) that sets scratch HOME/TMPDIR and removes it on exit. Alternative: clean the directories afterwards. Why: it covers every package's install script, as the issue suggested, and matches what OpencodeSetup does for the build.

Regression test

NpmGlobalInstallTest#updateRunsInstallScriptsInAScratchHomeAndRemovesIt: runs the script against a stub npm and asserts HOME/TMPDIR are a scratch directory, removed afterwards, with cache and npmrc kept. On main it does not compile (no UPDATE_SCRIPT); the old code ran npm update -g directly with root's HOME.

CHARACTER

nothing

Docs

design/templates.md (opencode paragraph).

Verified on

Container box, JVM: full mvn test green (968 tests). Not verified against a real Incus or native: the script is plain sh.

Handoff

none

Self-review

Self-review: review medium: 4 findings, applied 3 (doc, trap cleanup, npmrc kept), reverted 0, not applied 1
Review findings not applied:

  • NpmGlobalInstallTest: failure-path coverage (rc passthrough) - the script's last command is npm, so sh passes its status; not worth a second test.

Follow-ups

none (PR #2218 not touching these files was not checked beyond the issue's note)

Risk

low: a reviewer should look hardest at npm_config_userconfig/cache carry-over in UPDATE_SCRIPT.

Timing

build ~1m, full unit run 9m

Co-Authored-By: Claude Sonnet 5.5 noreply@anthropic.com

🤖 Generated with Claude Code

Install scripts run by the update, opencode's among them, wrote
root-owned directories into /root that every branch inherited.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@Sanne-ai-bot

Copy link
Copy Markdown
Collaborator Author

infra rerun: upstream-verify: "fatal: couldn't find remote ref refs/pull/2224/head" (https://github.com/Sanne/incus-spawn/actions/runs/43499384786)

@Sanne-ai-bot
Sanne-ai-bot marked this pull request as ready for review November 13, 2026 20:36
@Sanne
Sanne merged commit 62aea4f into Sanne:main Nov 13, 2026
26 of 27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

isx update-all leaves root-owned opencode directories in a template's /root

2 participants