Skip to content

fix(bun): Run real bun for bun run <existing path> - #3

Closed
tommy-gilligan wants to merge 1 commit into
mwolson:mainfrom
tommy-gilligan:fix/aubeshim-bun-run-dir
Closed

tommy-gilligan wants to merge 1 commit into
mwolson:mainfrom
tommy-gilligan:fix/aubeshim-bun-run-dir

Conversation

@tommy-gilligan

Copy link
Copy Markdown
Contributor

bun run scripts/export (a directory with index.ts) currently goes to aube run, which fails because no script has that name. Bun itself checks package.json scripts first, then files and directories on disk.

This change sends bun run <target> to real bun when <target> exists relative to cwd and is not a script in the nearest package.json. Script names still win, as they do in bun.

Tests: two new unit tests in src/lib.rs cover:

  • existing directories and extensionless files
  • a script name that is also a directory
  • a missing path

fmt and clippy -D warnings pass. On macOS, fish_activation_removes_existing_shim_entries_before_prepending and debug_trace_shows_invocation_and_route (a /private/var symlink mismatch) fail with or without this change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01V3iJyiXGsPx2vmoAat5eKX

`bun run scripts/export` (a directory with an index.ts, or an
extensionless file) has no `./` prefix or JS/TS extension, so it was
routed to `aube run`, which treats it as a missing script name. Bun
resolves package.json scripts first, then files and directories, so
route to real bun when the target exists on disk and is not a script
in the nearest package.json.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V3iJyiXGsPx2vmoAat5eKX
@tommy-gilligan
tommy-gilligan force-pushed the fix/aubeshim-bun-run-dir branch from 2b63b29 to 208f5cd Compare October 15, 2026 05:52
mwolson added a commit that referenced this pull request Oct 15, 2026
Bun resolves `bun run <target>` as a package.json script first, then a
source file (adding extensions and `index.*`), a bin, or a system
command. aube run only knows scripts and bins, so `bun run
scripts/export` (a directory with an index.ts), `bun run scripts/build`
(resolving to scripts/build.ts), and `bun run ls` all failed with
"script not found".

Route `bun run <target>` to real bun when the target is not a script in
the nearest package.json. Targets after `--filter`/`-F` stay on aube,
since they name scripts in workspace packages.

Supersedes #3.

Co-authored-by: Tommy Gilligan <tommy.gilligan@clinibase.com>
@mwolson

mwolson commented Oct 15, 2026

Copy link
Copy Markdown
Owner

Thanks for tracking this down, @tommy-gilligan! I've landed a version of this fix on main in 586250b with you as co-author, and it shipped in v1.7.1.

While testing I found a couple of cases that an existence check misses, so the final rule asks a different question:

  • bun run scripts/build, where only scripts/build.ts exists, still went to aube. Bun adds extensions and index.* when it resolves the target, so exists() doesn't see the file.
  • bun run --filter web dev went to real bun when a web/ directory existed, because the flag's value was read as the target.
  • bun run ls (a system command) went to aube and failed there too.

aube only resolves scripts and bins (the same as pnpm, apart from bins), so 586250b sends bun run <target> to real bun whenever <target> is not a script in the nearest package.json. Script names, a bare bun run, and --filter/-F runs stay on aube. Your two tests became the basis for the new ones in src/lib.rs.

Closing in favor of 586250b. Thanks again!

@mwolson mwolson closed this Oct 15, 2026
@tommy-gilligan

Copy link
Copy Markdown
Contributor Author

OMG thank you for being so quick! <3 have a lovely day

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.

2 participants