claude-code - 💡(How to fix) Fix Bash tool does not inherit PATH from launching shell environment

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

When Claude Code is launched from a shell, the Bash tool does not inherit the PATH (or other environment variables) from the parent process. This means tools that are available in the launching shell are not available in Claude Code's bash sessions.

Root Cause

When Claude Code is launched from a shell, the Bash tool does not inherit the PATH (or other environment variables) from the parent process. This means tools that are available in the launching shell are not available in Claude Code's bash sessions.

Fix Action

Fix / Workaround

  • Users on NixOS (and likely other distros using per-user package management) cannot use their installed tools inside Claude Code bash sessions
  • Workaround requires either hardcoding paths in settings.json env block (fragile, not portable) or wrapping the claude invocation with env PATH="$PATH" claude (non-obvious)
RAW_BUFFERClick to expand / collapse

Description

When Claude Code is launched from a shell, the Bash tool does not inherit the PATH (or other environment variables) from the parent process. This means tools that are available in the launching shell are not available in Claude Code's bash sessions.

Steps to Reproduce

  1. Install a tool via nix profile install (or any mechanism that adds to PATH at the user level, e.g. ~/.nix-profile/bin)
  2. Confirm the tool is available in your shell: which http/home/user/.nix-profile/bin/http
  3. Launch claude from that shell
  4. Ask Claude to run the tool via the Bash tool
  5. The tool is not found — Claude's bash sessions have a sanitized/reduced PATH

Environment

  • OS: NixOS
  • Shell: bash/zsh with Nix profile PATH (~/.nix-profile/bin, /run/current-system/sw/bin, etc.)

Expected Behavior

Claude Code's bash subprocesses should inherit the environment of the process that launched claude, just as any child process would by default in a Unix environment.

Actual Behavior

Claude Code spawns bash with a sanitized environment. Tools installed via user-level package managers (Nix profiles, ~/.local/bin, ~/go/bin, etc.) are not available, even though they are present in the launching shell's PATH.

Impact

  • Users on NixOS (and likely other distros using per-user package management) cannot use their installed tools inside Claude Code bash sessions
  • Workaround requires either hardcoding paths in settings.json env block (fragile, not portable) or wrapping the claude invocation with env PATH="$PATH" claude (non-obvious)

Suggested Fix

Inherit the parent process environment by default, or add a setting like "inheritEnv": true to settings.json that causes Claude Code to pass the launching process's environment to bash subprocesses.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix Bash tool does not inherit PATH from launching shell environment