Skip to content

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

Open
kagura-agent wants to merge 1 commit intoNVIDIA:mainfrom
kagura-agent:fix/prek-prepare-fallback
Open

fix(install): skip prek hook setup when binary not in PATH#1502
kagura-agent wants to merge 1 commit 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
    • Updated the installation preparation script to streamline git hook configuration. The script now gracefully skips hook setup when the required tool is unavailable, simplifying the overall setup process.

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: 7df42d4a-b0ec-46d6-a424-3a0b833dd866

📥 Commits

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

📒 Files selected for processing (1)
  • package.json

📝 Walkthrough

Walkthrough

The prepare script in package.json was simplified to remove fallback logic for a bundled @j178/prek package. The script now only runs prek install if available; otherwise, it logs a skip message while retaining the TypeScript build and dependency installation steps.

Changes

Cohort / File(s) Summary
Prepare Script Simplification
package.json
Removed bundled @j178/prek fallback logic from the prepare script; now directly checks for prek availability and logs skip message if absent.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A script so simple, clean, and bright,
No bundled paths to cloud the night,
Just ask: "Is prek around to stay?"
If not, we skip and go our way! 🌱

🚥 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 describes the main change: removing the problematic branch check and ensuring the prepare script gracefully skips prek hook setup when the prek binary is not available in PATH.
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant