Skip to content

bun run --filter, --parallel and --sequential ignore --shell and bunfig [run] shell #43232

Closed as not planned

Description

@robobun

What version of Bun is running?

1.4.3-canary.1+b52d51348 (also main at fd8422c)

What platform is your computer?

Linux x64 (the code path is the same on macOS)

What steps can reproduce the bug?

printf '{"name":"app","version":"1.0.0","scripts":{"which":"echo $0"}}' > package.json
bun run --shell=bun which                 # which            (Bun shell: $0 is the script name)
bun run --shell=system which              # /usr/bin/bash    (system shell)
bun run --shell=bun --filter '*' which    # app which: /usr/bin/bash

What is the expected behavior?

--shell=bun (and bunfig [run] shell = "bun") selects Bun's shell for --filter, --parallel, --sequential and --workspaces runs, as it does for a plain bun run <script>. docs/runtime/bunfig.mdx says shell = "bun" is the way "to always use Bun's shell instead of the system shell".

What do you see instead?

The system shell runs the script. On an image without a system shell (FROM scratch, oven/bun:distroless), bun run --shell=bun --filter '*' start and bun run --shell=bun --parallel start exit 1 with error: MissingShell.

Additional information

src/runtime/cli/filter_run.rs (near line 937) and src/runtime/cli/multi_run.rs (near line 910) pick the interpreter by platform only and never read ctx.debug.use_system_shell. POSIX always runs <sh> -c <script> with the result of find_shell. Windows always runs bun exec <script>, so --shell=system is ignored there.

#43231 fixes the plain bun run <script> path (run_command.rs) and does not touch these two runners. To honor the flag here changes which shell runs existing --filter scripts, so it needs its own change and tests. echo $0 tells the two shells apart without a special image.

Activity

  1. robobun commented on Sep 18, 2026

    @robobun
    CollaboratorAuthor

    Reproduced: bun run --shell=bun --filter "*" which prints /usr/bin/bash, the plain bun run --shell=bun which prints which.
    Fix in progress: #43235

  2. robobun commented on Sep 18, 2026

    @robobun
    CollaboratorAuthor

    Notes from a separate pass at this fix, for the change that lands. The branch is robobun/a9d825b4/filter-parallel-honor-shell-flag (one commit, no PR). I did not open a PR, because a fix is already announced above. Use any part of it.

    The direct fix is to read ctx.debug.use_system_shell and spawn bun exec <script> on POSIX when Bun's shell is wanted. That fix has two side effects.

    1. bun exec loads the package's .env files. sh -c and plain bun run --shell=bun do not. Measured with a package .env that sets LEAKED=yes and a script that echoes it:

    bun run --shell=system --filter dep0 script     -> LEAK=
    bun run --shell=bun --filter dep0 script        -> LEAK=yes   (direct fix)
    cd packages/dep0 && bun run --shell=bun script  -> LEAK=
    

    This brings #9635 to POSIX. The branch spawns bun exec --no-env-file <script>, which is what #38182 does. Jarred's draft #39403 already carries #38182's ScriptArgv and shell_bin: Option<&'static ZStr> in both runners. The branch has its own small helper. A version that lands should match the ScriptArgv shape, so the runner hunks do not conflict.

    2. --parallel fail-fast does not stop a running sibling under Bun's shell. The runner sends SIGINT to the direct child only. Bun's shell leaves SIGINT to its command and forwards nothing (src/spawn/ctrl_c.rs). bun run --parallel slow fail, where fail is sleep 1; exit 1:

    slow is sleep 10 slow is sleep 10; echo x
    system shell (bun 1.4.3) 1.1 s, sh -c execs the one command 10.0 s, x is printed
    Bun's shell, with the fix 10.3 s 10.4 s

    So the second column is how main behaves today. The fix moves one-command scripts of --shell=bun users into it. The runner waits for the sibling to exit, so a sibling that never exits keeps it alive. I did not test Ctrl+C from a terminal in that state. The branch does not solve this. #41802 (the shell forwards SIGTERM and SIGHUP) and #41478 (the runners wake on a signal) are the open changes that bear on it. A maintainer should decide if the fix can land before one of them.

    Verified on the branch

    • test/cli/run/filter-workspace.test.ts and test/cli/run/multi-run.test.ts pass with a debug build on Linux and on Windows x64. bun 1.4.3 fails the 8 new --shell=bun cases on Linux, and the 6 new .env cases on Windows x64.
    • No system shell: with the hide-paths helper from bun run: do not look for a system shell when --shell=bun runs the script #43231 and an empty PATH, bun 1.4.3 prints error: MissingShell for --shell=bun with --filter, --parallel and --sequential. The branch runs the script and exits 0. --shell=system still fails with MissingShell.
    • Windows stays on bun exec whatever the setting is. From a read of the code, cmd.exe there needs the forwarded-argument check that plain bun run has (batch_arg_has_cmd_metachars), and multi_run.rs quotes the bun path for Bun's shell. I did not test cmd.exe.
  3. added
    bugSomething isn't working
    cliSomething to do with CLI arguments
    on Sep 20, 2026
  4. Jarred-Sumner commented on Oct 8, 2026

    @Jarred-Sumner
    Collaborator

    Use handoff tool. GitHub issues are for user-facing issues and a user did not run into this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcliSomething to do with CLI arguments

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions