-
Notifications
You must be signed in to change notification settings - Fork 3.1k
bun run script.js
fails when script has node shebang
#4850
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
does this still reproduce for you? it appears to be working as of Bun 1.1.9. you may need to run |
@nektro yes, still reproducible in v1.1.9: |
ah I see. I was using |
talking with the team it seems this is somewhat intended behavior with an unfortunate error message given how many use cases are intersecting at this CLI. I will look into making the original call work but landing it may be low priority. hope this helps and will let u know about any developments! :) |
Thanks for looking into it! No rush, really. I probably wouldn't have filed the issue except for the fact that |
I get the same error even when the shebang specifies Bun rather than Node. Also, relative paths that don't start with DetailsI'm using Bun version 1.1.34 on Windows 11. I tested in Git Bash and CMD, both running inside Windows Terminal.
#!/usr/bin/env -S bun run --bun
console.log(Bun.version); // will throw ReferenceError if run in Node rather than Bun Spoiler: I never saw the Tested in Git Bashbun run test.js # error: Script not found "test.js"
bun run ./test.js # ok
bun run src/test.js # error: Script not found "src/test.js"
bun run ./src/test.js # ok More./test.js # ok
bun test.js # ok
bun ./test.js # ok
bun run test.js # error: Script not found "test.js"
bun run ./test.js # ok
bun run --bun test.js # ok
bun run --bun ./test.js # ok
mkdir -p src
cp test.js src/test.js
src/test.js # ok
./src/test.js # ok
bun src/test.js # ok
bun ./src/test.js # ok
bun run src/test.js # error: Script not found "src/test.js"
bun run ./src/test.js # ok
bun run --bun src/test.js # ok
bun run --bun ./src/test.js # ok
${PWD}/test.js # ok
bun ${PWD}/test.js # ok
bun run ${PWD}/test.js # ok
bun run --bun ${PWD}/test.js # ok
node test.js # ReferenceError (intended behavior) Tested in CMDbun run test.js &: error: Script not found "test.js"
bun run ./test.js &: ok
bun run .\test.js &: error: Script not found ".\test.js"
bun run src/test.js &: error: Script not found "src/test.js"
bun run src\test.js &: error: Script not found "src\test.js"
bun run ./src/test.js &: ok
bun run .\src\test.js &: error: Script not found ".\src\test.js" Morebun test.js &: ok
bun ./test.js &: ok
bun .\test.js &: ok
bun run test.js &: error: Script not found "test.js"
bun run ./test.js &: ok
bun run .\test.js &: error: Script not found ".\test.js"
bun run --bun test.js &: ok
bun run --bun ./test.js &: ok
bun run --bun .\test.js &: ok
mkdir src
copy test.js src\test.js
bun src/test.js &: ok
bun src\test.js &: ok
bun ./src/test.js &: ok
bun .\src\test.js &: ok
bun run src/test.js &: error: Script not found "src/test.js"
bun run src\test.js &: error: Script not found "src\test.js"
bun run ./src/test.js &: ok
bun run .\src\test.js &: error: Script not found ".\src\test.js"
bun run --bun src/test.js &: ok
bun run --bun src\test.js &: ok
bun run --bun ./src/test.js &: ok
bun run --bun .\src\test.js &: ok
bun %CD%/test.js &: ok
bun %CD%\test.js &: ok
bun run %CD%/test.js &: ok
bun run %CD%\test.js &: ok
bun run --bun %CD%/test.js &: ok
bun run --bun %CD%\test.js &: ok
node test.js &: ReferenceError (intended behavior) Changing the shebang to As @jakeboone02 noted, removing the shebang line entirely from |
This now works in |
Confirmed. Thanks! |
Uh oh!
There was an error while loading. Please reload this page.
What version of Bun is running?
1.0.0
What platform is your computer?
Darwin 22.6.0 x86_64 i386
What steps can reproduce the bug?
Example repo: https://github.com/jakeboone02/bun-run-script
What is the expected behavior?
bun run script.js
should run as if the user rannode script.js
when the node shebang is present.What do you see instead?
bun script.js
,bun --bun script.js
, andbun --bun run script.js
run whether or not the node shebang (#!/usr/bin/env node
) is present in script.js.bun run script.js
only runs if script.js does not have the node shebang.It appears that
bun run script.js
is passing off the execution tonode
as if "script.js" is a package.json script (i.e.npm run script.js
) rather than a standalone script (i.e.node script.js
).Additional information
No response
The text was updated successfully, but these errors were encountered: