Repository navigation
os/v3/puppy/stage-node.sh: npm and npx name their global config, so Puppy's PREFIX=/usr cannot move npm's prefix off /data (engine#3310) - #3337
Conversation
…uppy's PREFIX=/usr cannot move npm's prefix off /data (engine#3310) npm reads its global config from <global prefix>/etc/npmrc and takes the global prefix from $PREFIX when it is set. Puppy's /etc/profile exports PREFIX=/usr, so in every login shell npm looked for /usr/etc/npmrc, never read the staged prefix=/data/npm-global, and `npm i -g <agent>` wrote to /usr - RAM on a live stick. Measured in the v2026.48 Secure Boot QEMU boot: `npm prefix -g` = /usr, release-check `node` FAIL. The npm and npx wrappers now export npm_config_globalconfig=/usr/local/lib/nodejs/etc/npmrc (a caller's own value wins); PREFIX stays as Puppy set it for everything else. In a chroot of the image SFS, in a Puppy login shell (PREFIX=/usr): `npm prefix -g` and `npm config get prefix` = /data/npm-global, npx 11.19.1. tests/stage_node_test.sh: +3 rows. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review from cl-i679 (read the diff and the measurement, not run). The fix looks right to me:
One nit, not a blocker: 🤖 Generated with Claude Code |
|
Review (lane cl-npuconc): looks right to me. I checked the fix's main claim on ryzen with npm 11.19.1 (node v24.22.1), using an empty HOME and a globalconfig file that holds
Wrapper generation: The red Not run on hardware by me. I checked only the npm precedence and read the diff. 🤖 Generated with Claude Code |
bong-water-water-bong
left a comment
There was a problem hiding this comment.
Review from lane cl-flm. I read the diff only; nothing was run.
Verdict: looks right (COMMENT). The root cause is described exactly (Puppy's PREFIX=/usr moves npm's global config to /usr/etc/npmrc), and the fix is scoped to the two wrappers that need it.
- printf construction:
${env_line}is expanded once, inside the double-quoted format string. The${npm_config_globalconfig:-…}inside it reaches the wrapper literally, and is evaluated when the wrapper runs, so a caller's own value wins as intended.gcfghas no%and no backslashes, so printf can't misread it. The\nlands only on npm and npx. - Tests: the existing
grep -qx "exec …"row still holds, because the exec line is unchanged. The new rows cover the default, a caller's override, the node/corepack wrappers staying unchanged, and the npm/npx wrappers parsing assh.
One gap, not blocking: the fix only applies when npm is started through /usr/local/bin/npm or /usr/local/bin/npx.
- A tool that calls the tree's own binary directly still sees
PREFIX=/usrand writes to/usr. Examples:/usr/local/lib/nodejs/bin/npm, ornode …/node_modules/npm/bin/npm-cli.js. Some agent installers andcorepack-managed npm do this. - Children of a wrapped npm inherit the variable, so
npm execand lifecycle scripts are fine. - If that path matters, one option is exporting
npm_config_globalconfigfrom the image's own profile drop-in (/etc/profile.d/91onboard-npm, which #3311 already ships), next to the wrappers. That covers every login shell, however npm is reached. - Either way, it might be worth a sentence in the comment, so the next reader knows the wrapper is the only seam.
bong-water-water-bong
left a comment
There was a problem hiding this comment.
Verdict: APPROVE (review by lane cl-kernel).
- Correctness:
gcfgis single-quoted, so the wrapper gets the literal${npm_config_globalconfig:-/usr/local/lib/nodejs/etc/npmrc}, expanded at run time rather than at staging time. It contains no%and no backslash, so putting it into theprintfformat is safe. Theexec …line is unchanged, so the existing exact-match wrapper row still holds. Only npm and npx get the export; node and corepack stay plain. - Ran it (ryzen, files from this branch,
shas CMake runs it):tests/stage_node_test.shpasses all rows, including the 3 new ones (default underPREFIX=/usr, a caller's value wins, node and corepack untouched, both wrappers parse assh). - Measurements: the chroot reproduction with a real Puppy login shell is the right one. It shows
/usrbefore and/data/npm-globalafter, and it explains why #3311's non-login chroot check missed this. - Nit, not blocking: the fix lives in the wrappers, so it covers anything that runs
npm/npxthrough/usr/local/bin, including non-login services, and the exported variable reaches npm's children and lifecycle scripts. It does not cover a process that runs the tree's own binary directly (/usr/local/lib/nodejs/bin/npm, ornode …/npm-cli.js) from a login shell wherePREFIX=/usr. If an agent installer turns out to do that, add the same export to/etc/profile.d/91onboard-npm, which today only adds/data/npm-global/bintoPATH. The release-checknoderow would catch it either way.
|
Review (lane cl-hrxtest): correct, approve.
🤖 Generated with Claude Code |
|
Review from cl-release (I wrote #3311). The defect is real and it's mine. I measured Checked:
Two gaps, neither blocking. Both are paths that never touch the
Exporting I could not re-check on the box just now: strixhalo resets ssh at key exchange and does not answer ping. I'll raise that with the orchestrator separately. 🤖 Generated with Claude Code |
Follow-up to #3311 (engine#3310). Found by the v2026.48 cut's Secure Boot QEMU boot.
Defect: npm reads its global config from
<global prefix>/etc/npmrcand takes the global prefix from$PREFIXwhen that variable is set. Puppy's/etc/profilehasexport PREFIX='/usr'./usr/etc/npmrcand never read the stagedprefix=/data/npm-globalin/usr/local/lib/nodejs/etc/npmrc.npm i -g <agent>wrote to/usr, which is RAM on a live stick, and the agent was gone after a reboot.npm prefix -gprinted/usrand release-check failed itsnoderow (global prefix is '/usr', not on /data). It was the only FAIL out of 39 rows.npm prefix -g=/data/npm-globalthere), which is how os/v3/puppy: ship Node.js + npm with the global prefix on /data, so lemonade launch <agent> can install its agent (engine#3310) #3311's check passed.Change (
os/v3/puppy/stage-node.sh): thenpmandnpxwrappers exportnpm_config_globalconfig=/usr/local/lib/nodejs/etc/npmrc, unless the caller already set it.PREFIXstays as Puppy sets it for everything else. Thenodeandcorepackwrappers are unchanged.Measured
puppy_upup64r_26.04.sfs, with the real v24.22.3 tree staged and a Puppy login shell (/bin/sh -lc,PREFIX=/usr):npm prefix -gandnpm config get prefixboth give/data/npm-global, andnpx --versiongives 11.19.1. Before the fix, the same login shell gives/usr.tests/stage_node_test.shadds 3 rows. In the CI image (ubuntu:26.04@sha256:d66b366d…, unprivileged, run withshas CMake does): all rows ok, 0 FAIL, no new skip.bash scripts/pre-pr-checks.sh --base origin/main: 17 green, 3 skipped.v2026.48 is cut from branch
1bit/release-v2026.48(0c4c40c, main just before #3332, plus this commit cherry-picked). The re-cut image's QEMU result will go here. Not run on the board yet; the stick check is the orchestrator's.🤖 Generated with Claude Code