Skip to content

bun run should prioritize running script over file/directory #7735

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

Closed
PatrickMatthiesen opened this issue Dec 19, 2023 · 8 comments
Closed
Labels
bug Something isn't working bun install Something that relates to the npm-compatible client good first issue Something that would be good for new contributors

Comments

@PatrickMatthiesen
Copy link

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:
image
Note I removed the d in the script name to make it work

What do you see instead?

image

Additional information

I couldn't reproduce the issue with other flags but the --bun and -b flags.

@PatrickMatthiesen PatrickMatthiesen added the bug Something isn't working label Dec 19, 2023
@Electroid
Copy link
Contributor

Interesting, tried on macOS arm64.

> bun run --bun build
$ echo Hi
Hi
{
  "dependencies": {
    "express": "^4.18.2"
  },
  "scripts": {
    "build": "echo Hi"
  }
}

@Electroid Electroid added bun install Something that relates to the npm-compatible client needs investigate Needs to be investigated to find the root cause labels Dec 19, 2023
@PatrickMatthiesen
Copy link
Author

PatrickMatthiesen commented Dec 20, 2023

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?

@Electroid Electroid changed the title CLI: bun run --bun build gives Module not found bun run should prioritize running script over file/directory Dec 20, 2023
@Electroid Electroid added good first issue Something that would be good for new contributors and removed needs investigate Needs to be investigated to find the root cause labels Dec 20, 2023
@Electroid
Copy link
Contributor

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.

@paperclover
Copy link
Contributor

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

image

reminds me that i actually made this work if you run node as bun

image

I dont know if the logic can be copy pasted from this but it likely is possible.

@paperclover
Copy link
Contributor

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("

@aboqasem
Copy link

Debug logs:

Debug logs

@ryoppippi
Copy link

Is there any way to force bun to use script?

@RiskyMH
Copy link
Member

RiskyMH commented Jan 30, 2025

Should be fixed by @pfgithub in #15117

@RiskyMH RiskyMH closed this as completed Jan 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working bun install Something that relates to the npm-compatible client good first issue Something that would be good for new contributors
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants