Skip to content

Managed Bun toolchain: bunx shim drops argv0 dispatch — bunx <name> behaves as bun <name>, causing infinite self-recursion with common wrapper scripts #2123

Description

@beorn

Describe the bug

// package.json
"scripts": { "vitest": "bunx --bun vitest" }
bun vitest run                              # works
bunx -p vite-plus@0.2.4 vp run gate:test    # task = "bun vitest run"
# $ bunx --bun vitest run
# $ bunx --bun vitest run
# … repeats forever (~15/s, 119× in 8s); SIGABRT storm once the fspy shm ring exhausts

Why: vp's task PATH ships bunx as the same shim as bunexec "$basedir/bun.native" "$@". Real bunx is a symlink to bun; the binary dispatches on argv0 == "bunx" (bins only, never package.json scripts). The shim loses argv0, so in vp tasks bunx <args>bun <args> → the wrapper script re-invokes itself.

Proof it's the shim (same binary, different invoked name): .../bin/bunx probe runs the package.json SCRIPT; ln -s bun.native bunx && ./bunx probe runs the BIN.

Fix: ship unix bunx as a symlink to bun.native (as bun does), or exec "$basedir/bun.native" x "$@"; bunx.cmd/.ps1 have the same defect. Possibly explains #1627 (CI process explosion since v0.1.21, closed no-repro).

Reproduction URL

https://github.com/beorn/repro-vite-plus-bunx-shim

Steps to reproduce

Clone → bun installtimeout 8 bunx -p vite-plus@0.2.4 vp run gate:test.

System info

vp 0.2.4 (vp env n/a at 0.2.4); managed bun 1.3.14; system bun 1.3.x; node 24; macOS arm64.

Used Package Manager

bun

Validations

Not an upstream bun issue (symlink proof above). No prior report; nearest: #1971 / #1935 / #1948 / #2091, and #1627.


Disclosure: prepared with help from Claude Fable (Anthropic) as part of our Bun-monorepo → Vite+ effort; verified with live runs and human-reviewed.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Fields

Priority

None yet

Effort

None yet

Target date

None yet

Start date

None yet

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions