Skip to content

Agent threads: bb puts its CLI first on PATH, shadowing Babashka (bb) and breaking #!/usr/bin/env bb scripts #4417

Open

Description

@mturilin

Summary

In agent threads, the host daemon puts the directory containing the bb CLI at the front of PATH. bb is also the executable name of Babashka, a Clojure scripting runtime whose scripts start with #!/usr/bin/env bb. So every Babashka script run from a bb thread (or anything it starts) runs the bb CLI instead and fails. I expected the user's own bb to keep working, since agents already get the CLI's absolute path in BB_CLI.

Versions and environment

  • bb 0.43.4 (desktop app, Linux AppImage); CachyOS Linux, kernel 7.2.3
  • claude-code provider, Claude Code 2.1.283
  • Babashka v1.13.224 (installed with mise); it is the bb on the user's login-shell PATH
  • Login shell: fish

Steps to reproduce

  1. Install Babashka so that bb resolves to it in a normal terminal (bb --version prints babashka v…).

  2. In a bb agent thread, run:

    printf '#!/usr/bin/env bb\n(println "hello from babashka")\n' > /tmp/bb-repro.clj
    chmod +x /tmp/bb-repro.clj
    /tmp/bb-repro.clj

Did not reproduce: the same script run from a normal terminal outside bb prints hello from babashka.

Expected vs actual

Expected:
hello from babashka

Actual (exit 1):
error: unknown command '/tmp/bb-repro.clj'
Commands: browser, status, settings, project, provider, manager, machine, server, updates, terminal, thread, environment, file, theme, plugin, marketplace, skill, guide, diagnostics, voice
Plugins add commands only while they are installed and enabled. If '/tmp/bb-repro.clj' is a plugin command, check `bb plugin list`.

In the same thread:
$ command -v bb
/tmp/.mount_bb.AppkECNgb/resources/app.asar.unpacked/node_modules/bb-app/host-daemon/dist/bb

Evidence

  • prepareRuntimeShellEnv builds the agent shell env with PATH: prependPath(options.bbExecutableDirectory, inheritedPath) and also sets BB_CLI to the absolute CLI path:
    export function prepareRuntimeShellEnv(
    options: PrepareRuntimeShellEnvOptions,
    ): NonNullable<AgentRuntimeOptions["shellEnv"]> {
    const bbExecutablePath =
    options.bbExecutablePath ??
    resolveBbExecutablePathInDirectory(options.bbExecutableDirectory);
    const shellEnv: NonNullable<AgentRuntimeOptions["shellEnv"]> = {
    PATH: prependPath(
    options.bbExecutableDirectory,
    options.inheritedPath ?? process.env.PATH,
    ),
    BB_CLI: bbExecutablePath,
    BB_SERVER_URL: options.serverUrl,
    };
  • prependPath puts the directory first:
    function prependPath(
    executableDirectoryPath: string,
    inheritedPath?: string,
    ): string {
    return inheritedPath
    ? `${executableDirectoryPath}${delimiter}${inheritedPath}`
    : executableDirectoryPath;
    }
  • Thread where this was found and reproduced: thr_y8a8ded53t (project proj_99rhvwp7ur, environment env_kpkxu495rk).

What you ruled out

Suggested priority and effort (optional)

Medium: hits every Babashka user who runs scripts from bb threads; workaround is rewriting script shebangs; no data loss. Effort probably low: append the directory instead of prepending it, or drop it from PATH and rely on BB_CLI, or ship the CLI under a name nothing else uses.

Checks

  • I reproduced this on the latest release or on main, or I say above that I could not.
  • I searched open and closed issues for the same problem.
  • If an agent wrote this, the body ends with > AGENT GENERATED and links the thread or report.

Activity

  1. added theissue type on Sep 30, 2026
  2. added
    host
    cli
    partial-repro
    on Sep 30, 2026
  3. SawyerHood commented on Sep 30, 2026

    @SawyerHood
    Collaborator

    Report: https://get-bb.github.io/reports/issues/4417.html

    PARTIALLY REPRODUCED in two clean checkouts: the actual runtime environment builder changes Linux command lookup and env-shebang execution from an existing bb stub to the prepended product stub. Baseline and explicit-path controls pass; three desired-behavior assertions fail identically. Real Babashka, fish and provider sessions were not exercised.

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

    clihostpartial-repro

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions