Skip to content

fix(install): skip prek hook setup when binary not in PATH#1502

Merged
cv merged 2 commits intoNVIDIA:mainfrom
kagura-agent:fix/prek-prepare-fallback
Apr 10, 2026
Merged

fix(install): skip prek hook setup when binary not in PATH#1502
cv merged 2 commits intoNVIDIA:mainfrom
kagura-agent:fix/prek-prepare-fallback

Conversation

@kagura-agent
Copy link
Copy Markdown
Contributor

@kagura-agent kagura-agent commented Apr 5, 2026

Problem

PR #746 (merged) made prek optional in the prepare script, but introduced a regression: when node_modules/@j178/prek directory exists but the prek binary is not in PATH, the script errors with exit 1.

This happens in practice when running npm install --omit=dev (as the NemoClaw install script does) — the package directory may be present from a previous full install, but the binary won't be linked to PATH.

Reported by @DanTup on a clean Ubuntu VM: #746 (comment)

Root Cause

The prepare script tried to distinguish between "prek intentionally absent" and "prek should be here but isn't" by checking for the node_modules/@j178/prek directory. However, this distinction is unreliable — the directory can exist without the binary being available (e.g., after --omit=dev with a stale node_modules).

Fix

Remove the elif [ -d node_modules/@j178/prek ] branch entirely. If prek is not in PATH, simply skip hook setup regardless of whether the package directory exists.

Before:

if [ -d .git ]; then
  if command -v prek >/dev/null 2>&1; then prek install;
  elif [ -d node_modules/@j178/prek ]; then echo "ERROR: ..." && exit 1;  # ← BUG
  else echo "Skipping git hook setup (prek not installed)";
  fi
fi

After:

if [ -d .git ]; then
  if command -v prek >/dev/null 2>&1; then prek install;
  else echo "Skipping git hook setup (prek not installed)";
  fi
fi

Test Scenarios

Scenario Expected Result
.git exists + prek in PATH Runs prek install
.git exists + prek not in PATH + node_modules/@j178/prek exists Skip (no error) ✅ (was ❌ exit 1)
.git exists + prek not in PATH + no node_modules Skip
No .git directory Skip

Fixes regression from #746.

Summary by CodeRabbit

  • Chores
    • Simplified the installation preparation script to streamline git hook setup. When the required tooling isn't available, the script now gracefully skips hook configuration (and logs a skip) instead of failing, reducing setup friction for users.

Remove the elif branch that checked for node_modules/@j178/prek and
exited with an error.  After `npm install --omit=dev` the package
directory may linger while the binary is not linked, causing a
spurious failure on clean installs.  If prek is not on PATH, simply
skip hook setup regardless of node_modules state.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 5, 2026

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: 65847d11-5121-4dae-9f53-ef544816bdc0

📥 Commits

Reviewing files that changed from the base of the PR and between 754df31 and 98499b7.

📒 Files selected for processing (1)
  • package.json
🚧 Files skipped from review as they are similar to previous changes (1)
  • package.json

📝 Walkthrough

Walkthrough

The prepare script in package.json was simplified: it no longer attempts a vendored @j178/prek fallback and only runs prek install when prek is on PATH; otherwise, it logs a skip message if inside a Git repo.

Changes

Cohort / File(s) Summary
Prepare Script Simplification
package.json
Removed fallback branch that checked for a vendored node_modules/@j178/prek; the prepare script now only runs prek install when prek is available on PATH and otherwise prints a skip message without failing.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 I hopped through scripts both near and far,
Found a prepare that’s trimmed and star,
No bundled search, just a simple ask,
If prek’s present, it does the task,
If not, we skip and keep our spark. ✨

🚥 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 'fix(install): skip prek hook setup when binary not in PATH' accurately describes the main change: simplifying the prepare script to skip prek hook setup when the binary is not found in PATH, fixing a regression from PR #746.
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

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

@kagura-agent
Copy link
Copy Markdown
Contributor Author

Apologies for the extra round-trip — the original #746 should have been tested with a clean install from the start. Will be more thorough with lifecycle script changes going forward.

@wscurran wscurran added Platform: Ubuntu Support for Linux Ubuntu NemoClaw CLI Use this label to identify issues with the NemoClaw command-line interface (CLI). Docker Support for Docker containerization fix labels Apr 6, 2026
@wscurran
Copy link
Copy Markdown
Contributor

wscurran commented Apr 6, 2026

✨ Thanks for submitting this fix, which proposes a way to skip prek hook setup when the binary is not in PATH, resolving a regression that occurred during installation with --omit=dev.

Copy link
Copy Markdown
Contributor

@cv cv left a comment

Choose a reason for hiding this comment

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

LGTM — security review PASS.

  • Fixes false-positive from stale node_modules/@j178/prek directory breaking end-user installs
  • command -v prek is the correct POSIX check
  • Security hooks are enforced by CI server-side regardless of local hook state
  • "Skipping..." message still provides developer visibility
  • No injection risk, no privilege changes

No concerns.

@cv cv added the v0.0.11 Release target label Apr 9, 2026
@cv
Copy link
Copy Markdown
Contributor

cv commented Apr 9, 2026

Rebased onto current main (resolving conflict with the ts-migration stack from #1659).

Conflict resolution: Mechanical only — the ts-migration PR added adjacent lines (migrate:js-to-ts, ts-migration:*, bump:version) above the prepare script line. Kept all new scripts from main; applied the PR's fix to the prepare line (removed the elif [ -d node_modules/@j178/prek ] branch).

The contributor's fork is returning HTTP 503, so the rebased branch has been pushed to NVIDIA/NemoClaw at fix/prek-prepare-fallback (commit 0d9ef1ce). The diff against main is exactly the intended single-line change.

Tests: 66 passed, 2 failed (both pre-existing failures on maininstall-preflight.test.ts and migration-state.test.ts), 2 skipped.

@cv cv merged commit d3c1e49 into NVIDIA:main Apr 10, 2026
5 of 6 checks passed
ericksoa pushed a commit to cheese-head/NemoClaw that referenced this pull request Apr 14, 2026
## Problem

PR NVIDIA#746 (merged) made `prek` optional in the prepare script, but
introduced a regression: when `node_modules/@j178/prek` directory exists
but the `prek` binary is not in PATH, the script errors with `exit 1`.

This happens in practice when running `npm install --omit=dev` (as the
NemoClaw install script does) — the package directory may be present
from a previous full install, but the binary won't be linked to PATH.

Reported by @DanTup on a clean Ubuntu VM:
NVIDIA#746 (comment)

## Root Cause

The prepare script tried to distinguish between "prek intentionally
absent" and "prek should be here but isn't" by checking for the
`node_modules/@j178/prek` directory. However, this distinction is
unreliable — the directory can exist without the binary being available
(e.g., after `--omit=dev` with a stale `node_modules`).

## Fix

Remove the `elif [ -d node_modules/@j178/prek ]` branch entirely. If
`prek` is not in PATH, simply skip hook setup regardless of whether the
package directory exists.

**Before:**
```bash
if [ -d .git ]; then
  if command -v prek >/dev/null 2>&1; then prek install;
  elif [ -d node_modules/@j178/prek ]; then echo "ERROR: ..." && exit 1;  # ← BUG
  else echo "Skipping git hook setup (prek not installed)";
  fi
fi
```

**After:**
```bash
if [ -d .git ]; then
  if command -v prek >/dev/null 2>&1; then prek install;
  else echo "Skipping git hook setup (prek not installed)";
  fi
fi
```

## Test Scenarios

| Scenario | Expected | Result |
|----------|----------|--------|
| `.git` exists + `prek` in PATH | Runs `prek install` | ✅ |
| `.git` exists + `prek` not in PATH + `node_modules/@j178/prek` exists
| Skip (no error) | ✅ (was ❌ `exit 1`) |
| `.git` exists + `prek` not in PATH + no `node_modules` | Skip | ✅ |
| No `.git` directory | Skip | ✅ |

Fixes regression from NVIDIA#746.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Chores**
* Simplified the installation preparation script to streamline git hook
setup. When the required tooling isn't available, the script now
gracefully skips hook configuration (and logs a skip) instead of
failing, reducing setup friction for users.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Carlos Villela <cvillela@nvidia.com>
gemini2026 pushed a commit to gemini2026/NemoClaw that referenced this pull request Apr 14, 2026
## Problem

PR NVIDIA#746 (merged) made `prek` optional in the prepare script, but
introduced a regression: when `node_modules/@j178/prek` directory exists
but the `prek` binary is not in PATH, the script errors with `exit 1`.

This happens in practice when running `npm install --omit=dev` (as the
NemoClaw install script does) — the package directory may be present
from a previous full install, but the binary won't be linked to PATH.

Reported by @DanTup on a clean Ubuntu VM:
NVIDIA#746 (comment)

## Root Cause

The prepare script tried to distinguish between "prek intentionally
absent" and "prek should be here but isn't" by checking for the
`node_modules/@j178/prek` directory. However, this distinction is
unreliable — the directory can exist without the binary being available
(e.g., after `--omit=dev` with a stale `node_modules`).

## Fix

Remove the `elif [ -d node_modules/@j178/prek ]` branch entirely. If
`prek` is not in PATH, simply skip hook setup regardless of whether the
package directory exists.

**Before:**
```bash
if [ -d .git ]; then
  if command -v prek >/dev/null 2>&1; then prek install;
  elif [ -d node_modules/@j178/prek ]; then echo "ERROR: ..." && exit 1;  # ← BUG
  else echo "Skipping git hook setup (prek not installed)";
  fi
fi
```

**After:**
```bash
if [ -d .git ]; then
  if command -v prek >/dev/null 2>&1; then prek install;
  else echo "Skipping git hook setup (prek not installed)";
  fi
fi
```

## Test Scenarios

| Scenario | Expected | Result |
|----------|----------|--------|
| `.git` exists + `prek` in PATH | Runs `prek install` | ✅ |
| `.git` exists + `prek` not in PATH + `node_modules/@j178/prek` exists
| Skip (no error) | ✅ (was ❌ `exit 1`) |
| `.git` exists + `prek` not in PATH + no `node_modules` | Skip | ✅ |
| No `.git` directory | Skip | ✅ |

Fixes regression from NVIDIA#746.

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Chores**
* Simplified the installation preparation script to streamline git hook
setup. When the required tooling isn't available, the script now
gracefully skips hook configuration (and logs a skip) instead of
failing, reducing setup friction for users.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: Carlos Villela <cvillela@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Docker Support for Docker containerization fix NemoClaw CLI Use this label to identify issues with the NemoClaw command-line interface (CLI). Platform: Ubuntu Support for Linux Ubuntu v0.0.11 Release target

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants