Skip to content

Spawned agent shells inherit _VOLTA_TOOL_RECURSION, breaking bare node/npm/npx #1545

Closed

Description

@gsathya

Summary

Inside a shell spawned by bb, bare node, npm, and npx fail with Volta's "Node is not available" error, even though Volta is correctly configured with a default Node. Every #!/usr/bin/env node script fails the same way — including bb's own $BB_CLI entrypoint.

Cause

bb is installed as a Volta package, so Volta sets _VOLTA_TOOL_RECURSION=1 in bb's environment as its re-entrancy guard. bb passes that environment through to spawned agent shells, so every command in the session inherits it.

Volta's built-in runtime shims treat that variable as "this is a recursive call, do not re-evaluate the platform" (run/node.rs, same pattern in npm.rs, npx.rs, pnpm.rs, yarn.rs):

// Don't re-evaluate the platform if this is a recursive call
let platform = match env::var_os(RECURSION_ENV_VAR) {
    Some(_) => None,
    None => Platform::current(session)?,
};

With platform = None, execution_context falls through to System::path(), which strips Volta's own directories from PATH, and returns ErrorKind::NoPlatform. On a machine where Node is installed only through Volta there is no system Node left to fall back to, so the pass-through fails and Volta prints "Node is not available".

So the failure needs two ingredients: the leaked recursion guard, and no non-Volta Node on PATH. The error text is misleading in this situation — it recommends volta install node, which succeeds and changes nothing, because the install was never missing.

Reproduction

In a bb agent shell on a machine where Volta manages Node:

$ node --version
Volta error: Node is not available.

To run any Node command, first set a default version using `volta install node`

$ env -u _VOLTA_TOOL_RECURSION node --version
v25.0.0

Volta is healthy in that same shell, which is what makes the error misleading:

$ volta list | head -1
runtime [email protected] (default)

$ volta which node
~/.volta/tools/image/node/25.0.0/bin/node

That it is pass-through rather than a resolution failure can be shown directly — with the guard still set, giving the shim a real Node on PATH succeeds:

$ echo $_VOLTA_TOOL_RECURSION
1
$ PATH=~/.volta/tools/image/node/25.0.0/bin:$PATH node --version
v25.0.0

Scope

Only Volta's built-in runtime shims are affected — node, npm, npx — plus any #!/usr/bin/env node script. Package shims keep working, because they resolve through DefaultBinary::from_name and use the platform saved in the package's bin config at install time, never consulting the current/default platform (run/binary.rs). In practice pnpm, codex, and ~/.volta/bin/bb all run normally.

This bites bb specifically: $BB_CLI points at host-daemon/dist/bb, which is an #!/usr/bin/env node script, so it fails, while ~/.volta/bin/bb works. bb also prepends that dist directory as the first PATH entry, so bare bb resolves to the env-node copy rather than the Volta shim and fails too. The net effect is that an agent cannot invoke the bb CLI by any of the obvious routes.

Expected

A shell spawned by bb should behave like a normal user shell — bare node resolves through Volta's default platform.

Suggested fix

Strip _VOLTA_TOOL_RECURSION from the environment bb passes to spawned agent shells.

There is direct precedent in Volta itself: it removes the same variable before volta run for exactly this reason (run/mod.rs) — "Remove the recursion environment variable so that the context is correctly re-evaluated". A spawned agent shell is a new context in the same sense, so clearing the inherited value does not weaken the guard where it genuinely applies.

Workaround

Prefix affected commands with env -u _VOLTA_TOOL_RECURSION, or unset _VOLTA_TOOL_RECURSION in the shell profile.

Environment

  • bb 0.37.0
  • Volta 2.0.2 (source references above are tag v2.0.2)
  • Node 25.0.0 (Volta default), no system Node outside Volta
  • macOS, Darwin 25.5.0, zsh

Activity

  1. gsathya commented on Aug 13, 2026

    @gsathya
    Author

    Correcting the mechanism in the original description, which I had wrong on one point.

    I first wrote that the shim skips default-platform resolution and therefore cannot find Node. The skip is real, but the consequence is not a resolution failure: with platform = None, Volta falls through to System::path(), which strips Volta's own directories from PATH, and returns ErrorKind::NoPlatform. It is a pass-through to system Node. The error surfaces only because this machine has no Node outside Volta, so there is nothing to pass through to.

    That is demonstrable with the guard still set:

    $ echo $_VOLTA_TOOL_RECURSION
    1
    $ PATH=~/.volta/tools/image/node/25.0.0/bin:$PATH node --version
    v25.0.0
    

    So the trigger needs both the leaked recursion guard and the absence of a non-Volta Node on PATH. The description now cites the actual code paths in v2.0.2.

    The request is unchanged, and there is precedent for it in Volta itself: it removes this same variable before volta run, commented "Remove the recursion environment variable so that the context is correctly re-evaluated" (crates/volta-core/src/run/mod.rs, lines 57-60). A spawned agent shell is a new context in that same sense.

  2. added theissue type on Aug 13, 2026
  3. added
    host
    on Aug 18, 2026
  4. SawyerHood commented on Aug 18, 2026

    @SawyerHood
    Collaborator

    Reproduction & root-cause report: https://get-bb.github.io/reports/issues/1545.html

    • Verdict: REPRODUCED · root-cause confidence: high
    • Root cause (short): Volta stamps VOLTA_TOOL_RECURSION=1 on the bb-app it launches; bb forwards it to the daemon and sanitizeInheritedChildProcessEnv (packages/process-utils/src/index.ts:188) only strips BB*/NODE_ENV, while the daemon swaps PATH for the login-shell PATH that puts Volta's node/npm/npx shims back in front, so the shims see the guard, skip platform resolution and fail with "Node is not available" (also breaking $BB_CLI and bb, both #!/usr/bin/env node).
    • Proposed fix: Strip _VOLTA_TOOL_RECURSION in sanitizeInheritedChildProcessEnv (packages/process-utils/src/index.ts), the single choke point for every bb-spawned child (provider bridges, terminals, git, plugin hosts, script automations); one-hunk diff at /tmp/bb-reports/issues/1545/repro/proposed-fix.diff. Mirrors Volta's own volta run (removes the same var because a new command is a new context). No wire change, no protocol bump. Verified: repro test flips from fail to pass and the same Claude Code turn prints v24.19.0 while the daemon still carries the guard. Optional hardening: also drop it in bb-app cr…
    • Caveats: Reproduced on Linux with Volta 2.0.2 installed into a scratch VOLTA_HOME and a wrapper $SHELL so the daemon's login-shell PATH probe yields "Volta shims first, no other Node" (the reporter's mac/zsh setup is not available). The one simulated element is injecting _VOLTA_TOOL_RECURSION=1 into the dev instance's env instead of launching bb-app through a real Volta package shim; a real Volta package s…

    The report has copy-paste repro steps, screenshots where the bug is visual, code permalinks at 16ceb3a54, and repro artifacts. It was independently re-run by a second agent (see its Verification section).

    AGENT GENERATED: by Claude Opus 5

  5. added
    confirmed-repro
    on Aug 18, 2026
  6. SawyerHood commented on Aug 18, 2026

    @SawyerHood
    Collaborator

    Closing out since volta is no longer maintained

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

    confirmed-reprohost

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions