fix(install): configure npm for user-local installs to avoid EACCES on Linux#821
fix(install): configure npm for user-local installs to avoid EACCES on Linux#821MauroDruwel wants to merge 5 commits intoNVIDIA:mainfrom
Conversation
…on issues on Linux
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAdded a Linux-only Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Installer as "install.sh"
participant npm as "npm config"
participant Shell as "shell rc files"
User->>Installer: run install script
Installer->>npm: npm config get prefix
alt prefix not writable
Installer->>Installer: mkdir ~/.npm-global
Installer->>npm: npm config set prefix ~/.npm-global
Installer->>Installer: export PATH=~/.npm-global/bin:$PATH (current proc)
Installer->>Shell: append export block to ~/.bashrc / ~/.zshrc if missing
else prefix writable
Installer->>Installer: no-op
end
Installer->>Installer: call install_nemoclaw (uses adjusted env)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
✨ Thanks for submitting this PR, it addresses a bug that could cause issues during installation on Linux systems. |
Summary
On standard Linux systems where Node.js is installed via the system package
manager (apt, dnf, pacman, etc.), the npm global prefix defaults to
/usror/usr/local— directories that require root to write to. This causesnpm linkto fail with
EACCES: permission deniedand leaves the installer with a crypticerror message and no recovery path. This PR adds a
fix_npm_permissionsstep(matching the pattern already used in the upstream OpenClaw installer) that
detects the condition before
npm linkruns and silently redirects the prefixto
~/.npm-global, eliminating the failure entirely without requiring sudo.Related Issue
Related to #364
The npm EACCES permission error is one of the common installation failures
documented in that issue. This PR fixes the root cause in the installer so
users on system-managed Node.js no longer hit the error at all.
Changes
fix_npm_permissions()function ininstall.shthat:npm config get prefixis user-writable./usr,/usr/local), redirects the npm globalprefix to
~/.npm-global.export PATH="$HOME/.npm-global/bin:$PATH"to~/.bashrcand~/.zshrc(only if the file exists and the entry is not already present).PATHfor the current installer session.fix_npm_permissionsinmain()immediately beforeinstall_nemoclawso the correct prefix is always in place before
npm linkruns.Type of Change
Testing
npx prek run --all-filespasses (or equivalentlymake check).npm testpasses.make docsbuilds without warnings. (for doc-only changes)Manual reproduction:
Tested on:
apt/usr~/.npm-globalnvm~/.nvm/…(writable)brew/opt/homebrewChecklist
General
Code Changes
npx prek run --all-filesauto-fixes formatting (ormake formatfor targeted runs).Doc Changes
Prior art / comparison
Two earlier PRs attempted to fix this:
sudo npm linksudo~/.npm-global~/This approach is the one recommended in NemoClaw's own troubleshooting docs
and is already used verbatim in the upstream OpenClaw installer. It avoids
elevated privileges entirely, works in any non-interactive environment, and
has no impact on users who already have a writable prefix (nvm, fnm, Volta,
or a manually configured
~/.npm-global).Summary by CodeRabbit