Skip to content

fix(run): add node-gyp bootstrap to script PATH#518

Merged
jdx merged 3 commits intomainfrom
codex/node-gyp-script-path
May 5, 2026
Merged

fix(run): add node-gyp bootstrap to script PATH#518
jdx merged 3 commits intomainfrom
codex/node-gyp-script-path

Conversation

@jdx
Copy link
Copy Markdown
Contributor

@jdx jdx commented May 5, 2026

Summary

  • Reuse the existing node-gyp bootstrap when running package scripts through aube run / aube test.
  • Prepend the bootstrapped node-gyp .bin to script PATH when ambient PATH has no node-gyp.
  • Port pnpm's lifecycleScripts.ts:128 coverage into the offline node-gyp bootstrap BATS file and update the import tracker.

Root Cause

Dependency lifecycle scripts already used aube's node-gyp bootstrap path, but regular package script execution only prepended the project's node_modules/.bin. If the host PATH did not already contain node-gyp, aube test could fail with node-gyp: not found, diverging from pnpm/npm script behavior.

Validation

  • cargo fmt --check
  • cargo check -p aube
  • cargo build
  • mise run test:bats test/node_gyp_bootstrap.bats
  • cargo clippy -p aube --all-targets -- -D warnings
  • commit hook: cargo fmt, shellcheck, shfmt, cargo clippy

Note

Medium Risk
Touches script execution environment (PATH + new env vars) and adds a hidden bootstrap subcommand, which could affect how aube run/test executes user scripts across platforms if the shim/lookup logic misbehaves.

Overview
aube run/aube test now ensure node-gyp is available to package scripts when it’s not already on the ambient PATH, by prepending a lazy node-gyp shim bin dir (and passing AUBE_NODE_GYP_EXE/AUBE_NODE_GYP_PROJECT_DIR) alongside the project’s node_modules/.bin.

The existing install-time node-gyp bootstrap has been refactored to expose cached-ensure and shim helpers, and a hidden __node-gyp-bootstrap CLI subcommand was added to print the resolved bootstrapped binary path (used by the lazy shim). Tests and the pnpm import tracker were updated to cover direct, indirect, workspace-root, and no-bootstrap scenarios.

Reviewed by Cursor Bugbot for commit 365d26c. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented May 5, 2026

Greptile Summary

This PR adds node-gyp availability to aube run/aube test scripts via a lazy shim: when node-gyp is absent from both the ambient PATH and the project's node_modules/.bin, a thin wrapper script is prepended to the child process PATH that only triggers the actual bootstrap (aube __node-gyp-bootstrap) on first invocation. Unrelated scripts pay only the cost of a shim file write; the registry is never contacted unless a script actually calls node-gyp.

  • node_gyp_bootstrap.rs gains ensure_cached, lazy_shim_bin_dir, and print_bootstrapped_binary, while ensure delegates to the new helpers; build_script_command in run.rs is made async to accommodate the new PATH construction.
  • A hidden __node-gyp-bootstrap <PROJECT_DIR> CLI subcommand is wired up in main.rs/aube.usage.kdl so the shim script can resolve the bootstrapped binary path at runtime without embedding a hardcoded path.
  • Five new BATS test cases cover the direct, indirect-subprocess, workspace-root, unrelated-script (cold-cache + unreachable-registry), and project-local-bin scenarios.

Confidence Score: 5/5

Safe to merge; the lazy shim correctly defers all registry access until node-gyp is actually invoked by a script.

The core concerns from previous review threads are fully resolved by the lazy mechanism. Remaining observations are minor style nits that do not affect correctness or reliability.

No files require special attention.

Important Files Changed

Filename Overview
crates/aube/src/commands/install/node_gyp_bootstrap.rs Refactored to expose ensure_cached and lazy_shim_bin_dir; adds a lazy shim mechanism and print_bootstrapped_binary for the hidden CLI subcommand. Shim files are unconditionally rewritten on each invocation where the fast-path doesn't fire.
crates/aube/src/commands/run.rs build_script_command is now async and prepends the lazy shim bin dir to PATH; sets AUBE_NODE_GYP_EXE/AUBE_NODE_GYP_PROJECT_DIR unconditionally even when the shim is not active.
crates/aube/src/main.rs Adds hidden __node-gyp-bootstrap subcommand that delegates to print_bootstrapped_binary; placed correctly before alphabetically-ordered commands per repo convention.
test/node_gyp_bootstrap.bats Five new BATS test cases covering: direct bootstrap, unrelated-script safety (cold cache + unreachable registry), indirect subprocess access, workspace-root propagation, and project-local node-gyp bypass.
crates/aube/src/commands/install/mod.rs Trivial visibility change: node_gyp_bootstrap module promoted to pub(crate) so run.rs can access it.
aube.usage.kdl Adds hidden __node-gyp-bootstrap command definition with a PROJECT_DIR arg.

Fix All in Claude Code

Reviews (4): Last reviewed commit: "[autofix.ci] apply automated fixes" | Re-trigger Greptile

Comment thread crates/aube/src/commands/run.rs Outdated
@jdx jdx force-pushed the codex/node-gyp-script-path branch from 0fb4ccb to 80038f9 Compare May 5, 2026 18:23
Comment thread crates/aube/src/commands/run.rs Outdated
Comment thread crates/aube/src/commands/run.rs Outdated
@jdx jdx force-pushed the codex/node-gyp-script-path branch from 80038f9 to f262ae9 Compare May 5, 2026 18:41
Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f262ae9. Configure here.

Comment thread crates/aube/src/commands/run.rs Outdated
Comment thread crates/aube/src/commands/run.rs Outdated
@jdx jdx merged commit 9f65003 into main May 5, 2026
16 checks passed
@jdx jdx deleted the codex/node-gyp-script-path branch May 5, 2026 21:02
@greptile-apps greptile-apps Bot mentioned this pull request May 5, 2026
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