bun
bun copied to clipboard
`bun run` should prioritize running script over file/directory
What version of Bun is running?
1.0.18+1a2643520
What platform is your computer?
Linux 5.15.133.1-microsoft-standard-WSL2 x86_64 x86_64
What steps can reproduce the bug?
Simply have a script called build
and try to run it with the --bun
flag
What is the expected behavior?
The script should run like the following:
Note I removed the
d
in the script name to make it work
What do you see instead?
Additional information
I couldn't reproduce the issue with other flags but the --bun and -b flags.
Interesting, tried on macOS arm64.
> bun run --bun build
$ echo Hi
Hi
{
"dependencies": {
"express": "^4.18.2"
},
"scripts": {
"build": "echo Hi"
}
}
I did some more testing and figured out that it's because I have a directory that is named build. So it is an issue if a script and folder in the path have the same name. I would assume it's because Bun will prioritize the folder over the script name?
Yep, looks like that's the issue. We should fix this so bun run [name]
prioritizes running the script, before checking for a file/directory.
ah, is it checking for an item named [name] and then finding the directory, then giving up?
actually no, we dont run the module resolver for script names
reminds me that i actually made this work if you run node as bun
I dont know if the logic can be copy pasted from this but it likely is possible.
idk if this is a goodfirstissue but if someone wants to investigate the code, run command starts in run_command.zig line 1032 "pub fn exec("
Debug logs:
Is there any way to force bun to use script?