fix(install): surface npm link failures and fall back to user-local shim#2520
Conversation
## Summary A fresh `git clone` + `npm install` on a Linux host without a writable global npm prefix (and without sudo) reported success, but the `nemoclaw` command never landed on PATH. Root cause: the package.json `prepare` script invoked `NEMOCLAW_INSTALLING=1 npm link 2>/dev/null || true`, which suppressed both stderr and the exit code, so any link failure was invisible to the user. They only discovered it when `nemoclaw onboard` returned "No such file or directory". Replace the silent npm-link step with a small helper that surfaces the real npm error and falls back to a user-local wrapper at `~/.local/bin/nemoclaw`. Wrapper preserves the Node directory that was on PATH at install time so it works in shells where Node is provisioned via nvm. uninstall.sh recognises the new shim shape so a later uninstall cleans it up alongside the installer wrapper. ## Related Issue Closes #2515 ## Changes - scripts/npm-link-or-shim.sh: new helper invoked by `npm install` via the package.json `prepare` script. `set -eu` so any unchecked failure halts. Runs `npm link` from the repo root; on failure, prints the captured npm error then writes a wrapper at `~/.local/bin/nemoclaw` that exports the captured Node directory and execs `bin/nemoclaw.js`. Refuses to overwrite a foreign file (only refreshes a NemoClaw-managed shim, identified by a marker line). Atomic write via tempfile + rename so a mid-write failure cannot leave a partial unrecognisable file. Honours an already-set `NEMOCLAW_INSTALLING` to short-circuit prepare-script recursion. - package.json: replace the inline `NEMOCLAW_INSTALLING=1 npm link 2>/dev/null || true` with `bash scripts/npm-link-or-shim.sh`. Lenient chaining preserved (the helper warns loudly on stderr but does not fail `npm install`). - uninstall.sh: extend `is_installer_managed_nemoclaw_shim` to also recognise the dev-shim shape (marker line + same wrapper structure) so a later `uninstall.sh` removes it cleanly instead of leaving a stale `nemoclaw` command behind after the source checkout is gone. - test/npm-link-or-shim.test.ts: regression tests covering six cases — shim is created on link failure (wrapper structure, marker line, Node-directory PATH export), no shim on success, no-op when `NEMOCLAW_INSTALLING` is preset, refusal to overwrite a foreign file, idempotent refresh of an existing dev-shim, and the original high-severity reproduction (`~/.local` exists as a regular file). - test/uninstall.test.ts: regression test that a dev-shim file in `~/.local/bin/nemoclaw` is removed by `remove_nemoclaw_cli`. Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughAttempts Changes
Sequence Diagram(s)sequenceDiagram
participant npm as npm (client)
participant prepare as prepare script
participant repo as Repo (bin/nemoclaw.js)
participant fs as User FS (~/.local/bin)
npm->>prepare: run prepare during install
prepare->>repo: verify bin/nemoclaw.js executable
prepare->>npm: attempt `npm link` (capture logs)
alt npm link succeeds
npm-->>prepare: success
prepare->>fs: no shim needed (linked globally)
else npm link fails
npm-->>prepare: failure + logs
prepare->>fs: create managed shim at ~/.local/bin/nemoclaw (atomic write, make executable)
prepare->>npm: print shim creation and PATH instruction
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Review rate limit: 8/10 reviews remaining, refill in 11 minutes and 57 seconds. Comment |
|
✨ Thanks for submitting this pull request that proposes a way to fix a bug where npm link failures were not surfaced and fell back to a user-local shim. This identifies a bug and proposes a change to surface the real npm error and fall back to a user-local wrapper at ~/.local/bin/nemoclaw, with matching recognition in uninstall.sh to clean up the shim later. The addition of a hardened set -eu helper script and updates to package.json and uninstall.sh will help ensure the issue does not recur. Related open issues: |
## Summary Refreshes the daily docs from NemoClaw commits merged in the past 24 hours and advances the docs metadata from 0.0.29 to 0.0.31, the next version after tag v0.0.30. The updates cover documented behavior gaps found in the merged PRs listed below. ## Related Issue None. ## Changes - `docs/versions1.json` and `docs/project.json`: bump the preferred docs version to `0.0.31` for daily release preparation after latest tag `v0.0.30`. - `docs/reference/commands.md`: document non-interactive Brave Search validation fallback from #2511 / 9bfe30b, missing `--from <Dockerfile>` path validation from #2597 / 7186834, and `logs` reading OpenShell audit events from #2590 / e225dfb. - `docs/inference/use-local-inference.md`: document local inference reachability retry and host-side fallback from #2453 / 9dbe855, plus compatible-endpoint timeout coverage from #2583 / b4ef3db. - `docs/reference/troubleshooting.md`: document source-install shim fallback from #2520 / 01a177c, TLS gateway trust recovery from #1936 / 24725d2, compatible-endpoint timeout coverage from #2583 / b4ef3db, local reachability diagnostics from #2453 / 9dbe855, and host proxy `NO_PROXY` injection from #2662 / b4df07e. ## Type of Change - [ ] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [x] Doc only (includes code sample changes) ## Verification - [ ] `npx prek run --all-files` passes - [ ] `npm test` passes - [ ] Tests added or updated for new or changed behavior - [x] No secrets, API keys, or credentials committed - [x] Docs updated for user-facing behavior changes - [x] `make docs` builds without warnings (doc changes only) - [x] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [ ] New doc pages include SPDX header and frontmatter (new pages only) Additional verification: - `python3 scripts/docs-to-skills.py docs/ .agents/skills/ --prefix nemoclaw-user --dry-run` passed. - `git diff --check` passed. - Pre-push hooks passed through markdownlint, docs-to-skills, JSON checks, gitleaks, and version sync before `Test (skills YAML)` failed because this fresh worktree lacked `vitest/config`. - `npx prek run --all-files` could not run from the fresh worktree because `npx prek` resolved to a missing `prek@*` package; downloading `@j178/prek` was not approved. - `npm test` could not complete from the fresh worktree because dependencies and compiled `dist/lib/*` artifacts were absent. ## AI Disclosure - [x] AI-assisted — tool: OpenAI Codex --- Signed-off-by: Miyoung Choi <miyoungc@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Version updated to 0.0.31 * Local inference onboarding now includes retry logic for container reachability checks * Web search setup failure handling clarified with fallback guidance * Dockerfile path validation timing documented * Logging behavior clarified for concurrent stream reading * New TLS/certificate troubleshooting section added * Install path and proxy configuration troubleshooting updated <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Miyoung Choi <miyoungc@nvidia.com>
…him (NVIDIA#2520) ## Summary A fresh `git clone` + `npm install` on a Linux host without a writable global npm prefix reported success but left no `nemoclaw` command on PATH — the `prepare` script's `npm link 2>/dev/null || true` swallowed both stderr and the exit code. This surfaces the real npm error and falls back to a user-local wrapper at `~/.local/bin/nemoclaw`. `uninstall.sh` recognises the new shim shape so it cleans up later. ## Related Issue Closes NVIDIA#2515 ## Changes - Add `scripts/npm-link-or-shim.sh`: hardened `set -eu` helper that runs `npm link` and on failure writes a wrapper at `~/.local/bin/nemoclaw`. Atomic write via tempfile + rename, marker-based refusal to overwrite foreign files, idempotent refresh of NemoClaw-managed shims. - `package.json`: `prepare` now invokes the helper instead of swallowing errors inline. - `uninstall.sh`: `is_installer_managed_nemoclaw_shim` recognises the dev-shim shape so `remove_nemoclaw_cli` cleans it up. - `test/npm-link-or-shim.test.ts` (new) + `test/uninstall.test.ts`: regression coverage for six failure/success paths plus the uninstaller cleanup. ## Type of Change - [x] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [ ] Doc only (includes code sample changes) ## Verification - [x] `npx prek run --all-files` passes - [x] `npm test` passes - [x] Tests added or updated for new or changed behavior - [x] No secrets, API keys, or credentials committed - [ ] Docs updated for user-facing behavior changes - [ ] `make docs` builds without warnings (doc changes only) - [ ] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [ ] New doc pages include SPDX header and frontmatter (new pages only) ## AI Disclosure - [x] AI-assisted — tool: Claude Code, Codex --- Signed-off-by: Tinson Lai <tinsonl@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Enhanced CLI installation flow with a new helper that attempts linking and falls back to creating a managed user-local shim for more reliable setup. * **Bug Fixes** * Updated uninstall logic to recognize and remove the new managed shim variant. * **Tests** * Added comprehensive tests covering install fallback, shim creation/idempotence, overwrite protection, and uninstall behavior. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Tinson Lai <tinsonl@nvidia.com>
## Summary Refreshes the daily docs from NemoClaw commits merged in the past 24 hours and advances the docs metadata from 0.0.29 to 0.0.31, the next version after tag v0.0.30. The updates cover documented behavior gaps found in the merged PRs listed below. ## Related Issue None. ## Changes - `docs/versions1.json` and `docs/project.json`: bump the preferred docs version to `0.0.31` for daily release preparation after latest tag `v0.0.30`. - `docs/reference/commands.md`: document non-interactive Brave Search validation fallback from NVIDIA#2511 / 9bfe30b, missing `--from <Dockerfile>` path validation from NVIDIA#2597 / 7186834, and `logs` reading OpenShell audit events from NVIDIA#2590 / e225dfb. - `docs/inference/use-local-inference.md`: document local inference reachability retry and host-side fallback from NVIDIA#2453 / 9dbe855, plus compatible-endpoint timeout coverage from NVIDIA#2583 / b4ef3db. - `docs/reference/troubleshooting.md`: document source-install shim fallback from NVIDIA#2520 / 01a177c, TLS gateway trust recovery from NVIDIA#1936 / 24725d2, compatible-endpoint timeout coverage from NVIDIA#2583 / b4ef3db, local reachability diagnostics from NVIDIA#2453 / 9dbe855, and host proxy `NO_PROXY` injection from NVIDIA#2662 / b4df07e. ## Type of Change - [ ] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [x] Doc only (includes code sample changes) ## Verification - [ ] `npx prek run --all-files` passes - [ ] `npm test` passes - [ ] Tests added or updated for new or changed behavior - [x] No secrets, API keys, or credentials committed - [x] Docs updated for user-facing behavior changes - [x] `make docs` builds without warnings (doc changes only) - [x] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [ ] New doc pages include SPDX header and frontmatter (new pages only) Additional verification: - `python3 scripts/docs-to-skills.py docs/ .agents/skills/ --prefix nemoclaw-user --dry-run` passed. - `git diff --check` passed. - Pre-push hooks passed through markdownlint, docs-to-skills, JSON checks, gitleaks, and version sync before `Test (skills YAML)` failed because this fresh worktree lacked `vitest/config`. - `npx prek run --all-files` could not run from the fresh worktree because `npx prek` resolved to a missing `prek@*` package; downloading `@j178/prek` was not approved. - `npm test` could not complete from the fresh worktree because dependencies and compiled `dist/lib/*` artifacts were absent. ## AI Disclosure - [x] AI-assisted — tool: OpenAI Codex --- Signed-off-by: Miyoung Choi <miyoungc@nvidia.com> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Version updated to 0.0.31 * Local inference onboarding now includes retry logic for container reachability checks * Web search setup failure handling clarified with fallback guidance * Dockerfile path validation timing documented * Logging behavior clarified for concurrent stream reading * New TLS/certificate troubleshooting section added * Install path and proxy configuration troubleshooting updated <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Miyoung Choi <miyoungc@nvidia.com>
Summary
A fresh
git clone+npm installon a Linux host without a writable global npm prefix reported success but left nonemoclawcommand on PATH — thepreparescript'snpm link 2>/dev/null || trueswallowed both stderr and the exit code. This surfaces the real npm error and falls back to a user-local wrapper at~/.local/bin/nemoclaw.uninstall.shrecognises the new shim shape so it cleans up later.Related Issue
Closes #2515
Changes
scripts/npm-link-or-shim.sh: hardenedset -euhelper that runsnpm linkand on failure writes a wrapper at~/.local/bin/nemoclaw. Atomic write via tempfile + rename, marker-based refusal to overwrite foreign files, idempotent refresh of NemoClaw-managed shims.package.json:preparenow invokes the helper instead of swallowing errors inline.uninstall.sh:is_installer_managed_nemoclaw_shimrecognises the dev-shim shape soremove_nemoclaw_clicleans it up.test/npm-link-or-shim.test.ts(new) +test/uninstall.test.ts: regression coverage for six failure/success paths plus the uninstaller cleanup.Type of Change
Verification
npx prek run --all-filespassesnpm testpassesmake docsbuilds without warnings (doc changes only)AI Disclosure
Signed-off-by: Tinson Lai tinsonl@nvidia.com
Summary by CodeRabbit
New Features
Bug Fixes
Tests