Skip to content

Environment variable values containing $HOME or ~ reach agents unexpanded, creating a literal $HOME/ folder in the workspace #5092

Open

Description

@pvinis

Summary

I set CLAUDE_CONFIG_DIR in Settings → Environment variables to $HOME/.claude-personal, the way I would write it in a shell. bb passes environment values through literally, so Claude Code treats the value as a relative path. It creates a folder named $HOME inside each thread's workspace, starts with an empty config there, and every turn fails with Not logged in · Please run /login. Neither the editor nor bb machine env set says that values are not expanded. The value field is a password input and saved values are never shown again, so the mistake can't be spotted after saving.

Versions and environment

  • bb desktop app 0.45.0 (desktop-v0.45.0, 129f621), macOS 27.2 (26B5091g), arm64
  • Claude Code 2.1.292
  • Local primary host only, default data dir and ports
  • Code read at main 68a1e8b

Steps to reproduce

Minimal, no provider needed:

  1. printf '%s' '$HOME/bb-repro' | bb machine env set BB_REPRO_DOLLAR --project <proj>
  2. printf '%s' '~/bb-repro' | bb machine env set BB_REPRO_TILDE --project <proj>
  3. bb terminal create --thread <thread in that project> --json --command 'printf "BB_REPRO_DOLLAR=%s\nBB_REPRO_TILDE=%s\nHOME=%s\n" "$BB_REPRO_DOLLAR" "$BB_REPRO_TILDE" "$HOME"; read -t 20 _'
  4. bb terminal output <terminal id>

With Claude Code:

  1. Settings → Environment variables → All projects: CLAUDE_CONFIG_DIR = $HOME/.claude-personal, a config dir that is logged in when given as an absolute path.
  2. Start a Claude Code thread in any project and send hi.

Expected vs actual

Actual, terminal repro:

BB_REPRO_DOLLAR=$HOME/bb-repro
BB_REPRO_TILDE=~/bb-repro
HOME=/Users/pavlos

Actual, Claude Code thread:

Provisioned thread
Provider environment resolved
Unhandled Claude Code event
Not logged in · Please run /login
Not logged in · Please run /login error

ps eww on the spawned claude --output-format stream-json … process shows CLAUDE_CONFIG_DIR=$HOME/.claude-personal. A directory literally named $HOME appeared in every workspace that ran a turn:

~/Source/projects/g2-crosshair/$HOME/.claude-personal
~/Source/clients/<client>/<repo>/$HOME/.claude-<account>
~/.bb/provider-maintenance-workspace/$HOME/.claude-personal

git status in both repos showed ?? $HOME/.

Expected: either bb expands the value the way a shell would, or it tells me when I save that values are used literally and $HOME / ~ are not expanded. Silently creating a config dir inside the repo is the worst outcome. The agent runs logged out, and the folder is easy to commit by accident.

Evidence

  • The daemon copies values verbatim into the child environment:
    for (const entry of entries) {
    if (typeof entry.value === "string") env[entry.name] = entry.value;
  • The editor's value field is type="password", and saved values only come back as Saved secret · enter to replace:
    <Input
    className="min-w-0 pr-9 font-mono"
    aria-label={`Value for ${row.name || `variable ${index + 1}`}`}
    type={revealed ? "text" : "password"}
    placeholder={
    row.value === null ? "Saved secret · enter to replace" : "VALUE"
    }
    value={row.value ?? ""}
    autoComplete="off"
    disabled={disabled}
    onChange={(event) => onValueChange(event.target.value)}
  • I found no expansion or validation of values in apps/cli/src/commands/machine-environment.ts, apps/server/src/services/machines/environment-settings.ts, or the daemon.
  • Changing the values to absolute paths fixed it: the same terminal check prints /Users/pavlos/.claude-personal, and claude auth status with that CLAUDE_CONFIG_DIR reports "loggedIn": true.

What you ruled out

Suggested fix

Values are often secrets, and expanding $… inside them would break real tokens that contain $. A warning seems safer than expansion: when a value starts with ~ or contains $NAME / ${NAME}, show a non-blocking note under the row in the editor and on stderr from bb machine env set, for example "Values are used literally. $HOME and ~ are not expanded; use an absolute path." Expanding only a leading ~/ or $HOME/ would also work. I'm happy to implement either one.

Suggested priority and effort

Small change. The workaround is to use absolute paths. No data is lost, but the agent runs logged out and a stray config dir lands in the repo.

Checks

  • I reproduced this on the latest release (desktop 0.45.0).
  • I searched open and closed issues for the same problem.
  • An agent wrote this. It was investigated in a Claude Code session outside bb, so there is no bb thread to link.

AGENT GENERATED

Activity

  1. added theissue type on Oct 7, 2026
  2. added
    host
    cli
    confirmed-repro
    on Oct 7, 2026
  3. bb-slop-cop commented on Oct 7, 2026

    @bb-slop-cop
    Contributor

    🚨 SLOP COP 🚨 · new-issue-autopilot

    • Classification: Bug · Priority: Medium · Effort: Low · Labels: host, cli, confirmed-repro.
    • Report: https://get-bb.github.io/reports/issues/5092.html
    • Verdict: REPRODUCED · Root-cause confidence: high. Repeated against trusted origin/main (68a1e8b) in two clean checkouts.
    • Root cause: CLI/storage preserve strings verbatim and the daemon copies them into child environments, without save-time guidance explaining that shell path syntax stays literal. Saved values are subsequently masked.
    • Evidence: Real CLI → HTTP API → encrypted SQLite → daemon helper → child shell; three home-relative spellings stay literal with empty stderr. The focused notice assertion fails in both runs; 13 existing related tests pass. Claude Code authentication itself was not tested.
    • No PR: A complete warning-only repair spans the app and CLI, outside this rule’s single-subsystem gate; interpolation would change secret-value semantics.

    AGENT GENERATED

  4. pvinis commented on Oct 7, 2026

    @pvinis
    Author

    happy to do a PR if i am allowed 👍

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

    cliconfirmed-reprohost

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions