Skip to content

fix: prevent nvm/fnm from overriding fake stubs in installer tests - #463

Closed
suh4s wants to merge 1 commit into
NVIDIA:mainfrom
suh4s:fix/installer-test-nvm-leak
Closed

suh4s wants to merge 1 commit into
NVIDIA:mainfrom
suh4s:fix/installer-test-nvm-leak

Conversation

@suh4s

@suh4s suh4s commented Mar 20, 2026 •

Copy link
Copy Markdown

Summary

Installer preflight tests fail on machines with nvm or fnm installed. The test stubs for node and npm get silently overridden by the real binaries.

Root Cause

All 6 spawnSync calls in install-preflight.test.js spread ...process.env, which leaks NVM_DIR (and FNM_DIR) into the child process. The installer's ensure_nvm_loaded() then sources $NVM_DIR/nvm.sh, which prepends the real Node.js bin directory to PATH — overriding the fake node/npm stubs the test set up.

Fix

Set NVM_DIR: "" and FNM_DIR: "" in each spawn's env to neutralize version manager detection without removing other needed env vars.

Changes

  • test/install-preflight.test.js — 6 lines changed (one per spawnSync call)

Test plan

  • All 21 tests pass on macOS with nvm installed (previously 18/21)
  • No behavioral change to the installer itself

Summary by CodeRabbit

  • Tests
    • Strengthened installer test isolation by controlling environment variables during test execution, ensuring more reliable and consistent testing of the installation process.

The installer tests create fake node/npm stubs and set PATH to use
them. But spreading ...process.env leaks NVM_DIR/FNM_DIR, causing
ensure_nvm_loaded() to source the real nvm.sh which puts the real
node/npm back on PATH — overriding the test stubs.

Set NVM_DIR and FNM_DIR to empty strings in all test spawn envs
so the installer's version manager detection is neutralized.

Root cause: tests only failed on machines with nvm installed.
Copilot AI review requested due to automatic review settings March 20, 2026 02:49
@coderabbitai

coderabbitai Bot commented Mar 20, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 53c55bc6-6c6c-46e2-97c0-9577e6fa3e02

📥 Commits

Reviewing files that changed from the base of the PR and between dbfd78c and 91f3719.

📒 Files selected for processing (1)
  • test/install-preflight.test.js

📝 Walkthrough

Walkthrough

The test harness now explicitly sets NVM_DIR and FNM_DIR environment variables to empty strings in all spawnSync invocations, replacing the previous behavior of inheriting process.env. This ensures shell and runtime manager environment variables are blanked during installer testing.

Changes

Cohort / File(s) Summary
Test Environment Setup
test/install-preflight.test.js
Updated spawnSync environment configuration to explicitly set NVM_DIR: "" and FNM_DIR: "" alongside existing HOME and PATH overrides, isolating installer execution from system runtime manager variables.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 Environment variables, cleared with care,
NVM and FNM vanish in thin air,
The tests run clean, no clutter about,
Shell managers silenced, all doubt cast out! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: preventing nvm/fnm environment variables from interfering with installer tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can use TruffleHog to scan for secrets in your code with verification capabilities.

Add a TruffleHog config file (e.g. trufflehog-config.yml, trufflehog.yml) to your project to customize detectors and scanning behavior. The tool runs only when a config file is present.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes flaky installer preflight tests on developer machines where nvm/fnm are installed by preventing version-manager detection from leaking into spawnSync subprocess environments (which could cause the real node/npm to override the test stubs).

Changes:

  • Override NVM_DIR and FNM_DIR to empty strings in each test spawnSync environment to prevent loading/sourcing version-manager shims.
  • Keep ...process.env while ensuring the tests’ stubbed PATH remains authoritative.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@wscurran

Copy link
Copy Markdown
Contributor

Thanks for sharing a fix for the issue with nvm/fnm overriding fake stubs in installer tests, this should make our tests more reliable.

@wscurran

Copy link
Copy Markdown
Contributor

Thanks for this — nvm/fnm interference with installer test stubs is a real flakiness source. The installer test setup has changed since March. Could you rebase against main and verify the fix still applies cleanly to the current test harness?

@wscurran

Copy link
Copy Markdown
Contributor

This PR still has merge conflicts against main. If the branch isn't updated in the next 7 days we'll close it to keep the queue healthy — feel free to reopen once it's rebased, or open a new PR. Thanks for contributing to NemoClaw!

@cv

cv commented Apr 29, 2026

Copy link
Copy Markdown
Collaborator

Closing due to inactivity

@cv cv closed this Apr 29, 2026
@wscurran wscurran added area: cli Command line interface, flags, terminal UX, or output bug-fix PR fixes a bug or regression needs: rebase PR needs rebase or conflict resolution and removed NemoClaw CLI labels Jun 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli Command line interface, flags, terminal UX, or output bug-fix PR fixes a bug or regression needs: rebase PR needs rebase or conflict resolution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants