Skip to content

fix(npm): preserve extensionless bin shims#369

Merged
jdx merged 2 commits intomainfrom
codex/fix-npm-bin-shims
Apr 28, 2026
Merged

fix(npm): preserve extensionless bin shims#369
jdx merged 2 commits intomainfrom
codex/fix-npm-bin-shims

Conversation

@jdx
Copy link
Copy Markdown
Contributor

@jdx jdx commented Apr 28, 2026

Summary

  • Keep the root npm package's published bin entries stable and extensionless: ./bin/aube, ./bin/aubr, and ./bin/aubx.
  • On Unix, continue copying or hardlinking the selected native binaries directly to those extensionless paths.
  • On Windows, copy or hardlink native binaries to sibling .exe files, then write the extensionless bin/<name> files as tiny shebang files pointing at those native .exe files. This gives npm's generated .cmd shims a stable target without adding a Node wrapper.
  • Normalize npm's Windows interpreter-shim argv shape in the native CLI, so aube.exe bin/aube ... parses as the intended aube ..., and aubr / aubx multicall dispatch still works.

Why

The current published npm package downloads/copies the platform binary during preinstall, then rewrites package.json from ./bin/aube to ./bin/aube.exe on Windows. npm/npx appear to resolve executable metadata before that rewrite matters, so global installs and fresh-cache npx installs can leave no runnable aube command.

This keeps the published bin paths stable for npm/npx while preserving extensionless command targets on Unix and keeping the runtime path native-only.

Validation

  • git diff --check
  • node -c npm/installArchSpecificPackage.js
  • rustup run 1.93.0 cargo test -p aube multicall_tests --bin aube
  • rustup run 1.93.0 cargo build -p aube --bin aube --bin aubr --bin aubx
  • Windows global-prefix smoke using a temp root package and temp local @endevco/aube-win32-x64 package built from the updated debug binaries: npm.cmd install --global --prefix <tmp> --ignore-scripts=false <pkg>, then <tmp>\\aube.cmd --version, <tmp>\\aubr.cmd --version, and <tmp>\\aubx.cmd --version all printed 1.3.0-DEBUG windows-arm64 (2026-04-28).
  • Windows npx smoke using a fresh cache and temp local platform package: npx.cmd --yes --package <fixed local package> aube --version printed 1.3.0-DEBUG windows-arm64 (2026-04-28).

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 28, 2026

Greptile Summary

This PR fixes npm/npx global install failures on Windows by keeping the root package's bin entries as stable extensionless paths (./bin/aube, ./bin/aubr, ./bin/aubx) instead of rewriting package.json at preinstall time. On Windows, installArchSpecificPackage.js now writes a tiny shebang file at each extensionless path pointing at the sibling .exe, and the Rust binary's normalize_npm_interpreter_shim_argv strips the shebang-file argument that npm's .cmd shim injects so multicall dispatch still works correctly.

Confidence Score: 5/5

Safe to merge; the approach is well-reasoned, validated end-to-end on Windows, and the only finding is a minor style suggestion.

Both changed files are correct and the new tests cover the key shim-drop and multicall-dispatch paths. The sole comment is a P2 style suggestion (adding a #[cfg(windows)] guard) that does not affect correctness.

No files require special attention.

Important Files Changed

Filename Overview
crates/aube/src/main.rs Adds normalize_npm_interpreter_shim_argv to rewrite [aube.exe, bin/aube, ...][bin/aube, ...] before multicall dispatch; two new tests cover the shim-drop and multicall-dispatch cases. Logic is correct; minor style note about missing #[cfg(windows)] guard.
npm/installArchSpecificPackage.js Removes the fragile package.json bin-rewrite on Windows and instead writes a tiny shebang shim (bin/<name>) pointing at the native bin/<name>.exe; root package.json bin paths stay stable and extensionless. Logic is correct and simplifies the install script.

Fix All in Claude Code

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

@jdx jdx force-pushed the codex/fix-npm-bin-shims branch from 2a5f93e to bdd2877 Compare April 28, 2026 19:06
@jdx jdx changed the title fix(npm): keep native bin paths stable fix(npm): keep native bin shims stable Apr 28, 2026
@jdx jdx changed the title fix(npm): keep native bin shims stable fix(npm): preserve extensionless bin shims Apr 28, 2026
@jdx jdx merged commit 5946c78 into main Apr 28, 2026
15 checks passed
@jdx jdx deleted the codex/fix-npm-bin-shims branch April 28, 2026 19:21
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