Skip to content
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

Bun Shell doesn't seem to search PATH correctly #9747

Open
DanielBaulig opened this issue Mar 30, 2024 · 0 comments
Open

Bun Shell doesn't seem to search PATH correctly #9747

DanielBaulig opened this issue Mar 30, 2024 · 0 comments
Labels
bug Something isn't working shell Something to do with Bun as a shell

Comments

@DanielBaulig
Copy link

DanielBaulig commented Mar 30, 2024

What version of Bun is running?

1.0.35

What platform is your computer?

Linux 5.15.146.1-microsoft-standard-WSL2 x86_64 unknown

What steps can reproduce the bug?

Create index.ts

import { $ } from 'bun';

await $`mkdir -p .mypath && echo '#!/bin/sh' > .mypath/prog && chmod a+x .mypath/prog && prog`.env({PATH: `.mypath:${process.env.PATH}`});

Run it

# bun index.ts
bun: command not found: prog

Try running equivalent from any shell:

# PATH=".mypath:$PATH" sh -c 'mkdir -p .mypath && echo ''#!/bin/sh'' > .mypath/prog && chmod a+x .mypath/prog && prog'
# 

What is the expected behavior?

Bun Shell should find and run prog

What do you see instead?

Bun Shell doesn't find prog, even though it's in the PATH for the Shell context.

Additional information

Note: the example can be more simple. For completeness sake I've included all the steps into a single command line. It seems like any executable file in any location will not be found by Bun Shell if that location was added to the Bun Shell environment PATH variable after bun startup, either locally or globally. (i.e. $`...`.env() or $.env()). Using an absolute path, a non-hidden path or adding the location to the end of PATH doesn't make a difference either. It's almost as if Bun Shell's search path is set upon bun execution and not updated by any calls to .env.

Changing the PATH variable before bun invocation resolves the issue, e.g.

PATH=".mypath:$PATH" bun index.ts
@DanielBaulig DanielBaulig added the bug Something isn't working label Mar 30, 2024
@Electroid Electroid added the shell Something to do with Bun as a shell label Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working shell Something to do with Bun as a shell
Projects
None yet
Development

No branches or pull requests

2 participants