fix(setup): mirror nvm init into .zshrc so zsh sees node + pnpm #255
Reference in New Issue
Block a user
Delete Branch "fix/dev-vm-nvm-zshrc"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fix the dev-VM bootstrap so
nodeandpnpmare onPATHin zsh sessions. On a fresh VM provisioned withdocs/setup/scripts/, a freshly-cloned checkout fails to run anything (command not found: pnpm, andnodetoo) because the nvm init never reaches the interactive shell.Root cause
Two setup scripts interact badly:
20-zsh.shpatches~/.bashrcwith anexec zsh -lhand-off on interactive shells (chsh is blocked on the corp VM, so this is how zsh becomes the effective shell), and patches~/.zshrcwith theme/plugins/fzf only.40-node.shruns the upstream nvm installer, which appends its init block to~/.bashrc(its default target).Because
20-zsh.shruns first, theexec zsh -lguard sits above the nvm block in~/.bashrc. On every interactive shell, bash execs into zsh before reaching the nvm block — so it never runs — and~/.zshrchas no nvm init at all. Net result: zsh sessions have neithernodenorpnpmonPATH, even though nvm + Node + corepack installed correctly.This is a procedure bug, not a one-off: every VM built from these scripts hits it.
Fix
40-node.shnow mirrors the nvm init block into~/.zshrcafter enabling corepack — idempotent via a managed marker, same pattern20-zsh.shalready uses for its~/.bashrcpatch:docs/setup/01-dev-debian-vm-setup.md— the40-node.shrow in the bootstrap table now notes the~/.zshrcpatch and why it is needed.What lands
docs/setup/scripts/40-node.sh~/.zshrcafter corepack enable.docs/setup/01-dev-debian-vm-setup.md~/.zshrcnvm patch in the40-node.shtable row.Manual remediation for already-provisioned VMs
VMs built before this fix won't be retroactively patched (the scripts are idempotent and skip already-installed nvm). On those, run once:
(Or re-run
40-node.shonce this lands — the marker check makes it safe; it will add the block and skip the rest.)Test plan
bash -n docs/setup/scripts/40-node.sh— syntax valid.exec zsh -l,node --version(v24) andpnpm --version(10.34.1) both resolve.node+pnpmresolve in the first zsh session with no manual step.40-node.shon an already-set-up VM is a no-op on the nvm install and adds the~/.zshrcblock exactly once (marker idempotency).Related
docs/setup/01-dev-debian-vm-setup.md— dev-VM bootstrap procedure.20-zsh.sh— owns the.bashrc→ zsh hand-off this fix complements.