fix(install): prevent nvm/login shell from resetting PATH in subshells#651
fix(install): prevent nvm/login shell from resetting PATH in subshells#651cv wants to merge 1 commit intoNVIDIA:mainfrom
Conversation
Two issues caused install_nemoclaw() subshells to lose the caller's PATH, making install-preflight tests fail on macOS while passing in CI: 1. `bash -lc` sourced /etc/profile which runs path_helper on macOS, resetting PATH to system defaults and hiding the caller's binaries. Fix: replace `bash -lc` with `bash -c` — the parent shell already has the correct PATH, so a login shell is unnecessary. 2. `ensure_nvm_loaded()` unconditionally sourced nvm.sh, which also resets PATH. Fix: skip sourcing when node is already on PATH. Also export `info` and `warn` helpers via `declare -f` so pre_extract_openclaw can use them in the subshell. Additionally: - Fix SC2206 shellcheck warning in version_gte() by using `read -ra` instead of unquoted word splitting into arrays. - Add .shellcheckrc to suppress SC2059 (printf format string with color vars) and SC1091 (dynamically sourced files) across the project. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
📝 WalkthroughWalkthroughAdded a ShellCheck configuration file to disable specific linting rules for intentional patterns in the project. Updated shell scripts to optimize NVM loading by short-circuiting when node exists on PATH, refactored semver parsing logic, and modified function declaration handling in build commands. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 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 Tip CodeRabbit can approve the review once all CodeRabbit's comments are resolved.Enable the |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
.shellcheckrc (1)
9-9: Scope ShellCheck suppressions more narrowly.Line 9 disables
SC2059andSC1091repo-wide, which can mask future issues outside installer helpers. Prefer keeping global config minimal and using local# shellcheck disable=...at intentional callsites.Example tightening
-disable=SC2059,SC1091 +disable=SC1091# In files with intentional colorized printf format strings: # shellcheck disable=SC2059 info() { printf "${C_CYAN}[INFO]${C_RESET} %s\n" "$*"; }🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In @.shellcheckrc at line 9, Remove the repo‑wide suppression of SC2059 and SC1091 from .shellcheckrc and instead scope those disables to specific call sites that intentionally require them (for example the colorized printf helper like info() and any installer helper that sources generated files), by adding local comments such as "# shellcheck disable=SC2059" or "# shellcheck disable=SC1091" directly above the offending function or source statement; keep the global .shellcheckrc minimal so other files still get checked.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In @.shellcheckrc:
- Line 9: Remove the repo‑wide suppression of SC2059 and SC1091 from
.shellcheckrc and instead scope those disables to specific call sites that
intentionally require them (for example the colorized printf helper like info()
and any installer helper that sources generated files), by adding local comments
such as "# shellcheck disable=SC2059" or "# shellcheck disable=SC1091" directly
above the offending function or source statement; keep the global .shellcheckrc
minimal so other files still get checked.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: dee031f5-e9f3-4ee0-b586-67c22701b172
📒 Files selected for processing (3)
.shellcheckrcinstall.shscripts/install.sh
Summary
bash -lc→bash -cininstall_nemoclaw()subshells. The login shell flag sourced/etc/profilewhich runspath_helperon macOS, resetting PATH to system defaults and hiding the caller's binaries.nvm.shsourcing when node is already on PATH.ensure_nvm_loaded()unconditionally sourcednvm.sh, which also resets PATH — breaking test stubs and unnecessarily mutating the environment.info/warnhelpers viadeclare -fsopre_extract_openclawcan use them in the subshell.version_gte()— useread -rainstead of unquoted word splitting..shellcheckrcto suppress SC2059 (printf format string with color vars) and SC1091 (dynamically sourced files).Why these tests failed locally but passed in CI
CI runs on
ubuntu-latestwith a minimal shell profile — no nvm, nopath_helper. On macOS with nvm installed, bothbash -l(via/etc/profile) andensure_nvm_loaded(vianvm.sh) reset PATH, causing the fake node/npm/git stubs ininstall-preflight.test.jsto be overridden by real system binaries.Test plan
node --test test/install-preflight.test.js— all 11 tests pass (previously 4 failed)node --test test/*.test.js— all 217 tests passnpx shellcheck install.sh scripts/install.sh— clean🤖 Generated with Claude Code
Summary by CodeRabbit
Chores
Performance