[BUG] PATH exports in shell config files ignored by Claude Code VS Code extension

Status Closed — not planned
Maintainer reply None cached
Activity 11 comments · opened Mar 14, 2026 · closed Apr 13, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

The Claude Code VS Code extension does not pick up PATH exports from shell config files (.bashrc, .profile). Binaries installed via Homebrew (or other package managers) are therefore not found by the Bash tool.

After investigation, the root cause is that Claude Code captures a shell snapshot at startup (~/.claude/shell-snapshots/). This snapshot sources .bashrc and .profile for aliases and functions, but takes PATH from VS Code's process environment — which is set by path_helper reading /etc/paths and /etc/paths.d/, not from shell config exports.

As a result, any export PATH=... in .bashrc or .profile is silently ignored.

What Should Happen?

PATH exports in .bashrc and .profile should be reflected in the shell snapshot, so that binaries available in the user's terminal are also available to Claude Code's Bash tool.

Workaround

Register the missing paths at the path_helper level (macOS):

sudo sh -c 'printf "/opt/homebrew/bin\n/opt/homebrew/sbin\n" > /etc/paths.d/homebrew'

View original on GitHub ↗

11 Comments

yurukusa · 5 months ago

This is a VSCode behavior, not specific to Claude Code. VSCode's integrated terminal spawns a non-interactive, non-login shell — so ~/.bashrc (which requires an interactive shell) isn't sourced.

Fixes (pick one)

Option 1: Set PATH in VSCode settings (recommended)

In your VSCode settings.json:

{
  "terminal.integrated.env.osx": {
    "PATH": "/your/custom/path:${env:PATH}"
  }
}

Option 2: Move PATH exports to a login profile

Put your PATH modifications in ~/.bash_profile or ~/.profile instead of ~/.bashrc. These are sourced by login shells, which VSCode can be configured to use:

{
  "terminal.integrated.profiles.osx": {
    "bash": {
      "path": "bash",
      "args": ["-l"]
    }
  }
}

The -l flag makes it a login shell, which sources ~/.bash_profile.

Option 3: Source bashrc from bash_profile

Add this to ~/.bash_profile:

[[ -f ~/.bashrc ]] && source ~/.bashrc

This ensures your bashrc config is loaded in both interactive and login shell contexts.

Why this affects Claude Code specifically

When Claude Code runs Bash tool calls in VSCode, they inherit the extension's environment — which has the truncated PATH. The CLI version (claude in a terminal) doesn't have this problem because your terminal is an interactive login shell that already sourced .bashrc.

Atcold · 5 months ago

Thanks, @yurukusa, for your answer.
I did update VSCode settings, but it's not working.

"terminal.integrated.defaultProfile.osx": "bash",
"terminal.integrated.env.osx": {
        "PATH": "/opt/homebrew/bin:/opt/homebrew/sbin:${env:PATH}"
    }

My path

/opt/homebrew/Caskroom/miniconda/base/condabin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/pmk/env/global/bin:/opt/X11/bin:/Library/TeX/texbin:/Users/atcold/.local/bin:/Users/atcold/.lmstudio/bin:/Users/atcold/go/bin:/Users/atcold/.local/bin

What Claude sees:

/opt/homebrew/opt/python@3.14/Frameworks/Python.framework/Versions/3.14/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/opt/pmk/env/global/bin:/opt/X11/bin:/Library/TeX/texbin
Atcold · 5 months ago

Ah, I think I figured.
VS Code does source ~/.profile.
My ~/.profile opens with source $HOME/.bashrc, and therefore it gets my aliases.
Yet, ~/.bashrc does not export brew stuff but runs /opt/homebrew/bin/brew shellenv, which doesn't get executed by VS Code.

So… well… I don't know.
A workaround would be simply exporting brew myself.
But a nicer solution would be…

sovetski · 5 months ago

Same problem here, @yurukusa I am not sure that it is "VS Code problem", I am also using GitHub Copilot and it works perfectly

Atcold · 5 months ago

Deep-dive investigation findings

I spent time systematically debugging this with Claude itself. Here's what we found.

How Claude Code's shell environment actually works

Claude Code does not run a fresh login shell for each Bash tool call. Instead, it captures a shell snapshot at startup, saved to ~/.claude/shell-snapshots/snapshot-bash-<timestamp>.sh. Every subsequent command replays this snapshot.

The snapshot has two independent sources:

| What | Source |
|------|--------|
| Aliases & functions | Sourced from ~/.bashrc and ~/.profile |
| PATH | VS Code's process environment at launch |

These are captured separately. export PATH=... statements in .bashrc or .profile are ignored for the snapshot's PATH — it comes from wherever VS Code itself inherited its PATH (typically path_helper reading /etc/paths + /etc/paths.d/).

Why brew shellenv doesn't help

The eval "$(brew shellenv)" block internally calls path_helper -s, which resets PATH from scratch based on /etc/paths and /etc/paths.d/. Since Homebrew is not registered in /etc/paths.d/ on my system, it never makes it into the process PATH — and therefore never into the snapshot.

Why terminal.integrated.env.osx doesn't help

That VSCode setting only affects the integrated terminal, not the environment inherited by the Claude Code extension process.

Broken symlink causes total failure

If ~/.bashrc is a broken symlink (e.g. the target file was renamed), snapshot generation fails entirely — not even ~/.profile aliases are captured. The snapshot requires ~/.bashrc to be sourceable.

What actually works

The only reliable fix is registering Homebrew at the path_helper level:

sudo sh -c 'printf "/opt/homebrew/bin\n/opt/homebrew/sbin\n" > /etc/paths.d/homebrew'

After this, VS Code's process PATH includes Homebrew, and therefore the snapshot's PATH does too.

Suggested fix for Claude Code

Claude Code should capture PATH (and other env vars) by sourcing the user's shell config files (.bashrc, .profile) rather than inheriting the process environment verbatim. Or at minimum, document that terminal.integrated.env.osx does not affect the Bash tool, and that /etc/paths.d/ is the correct fix on macOS.

sovetski · 5 months ago

I just saw this warning on VS Code terminal "The following extensions want to relaunch the terminal to contribute to its environment -> Claude Code for Vs Code"

Atcold · 5 months ago

@sovetski, did my workaround worked? I managed to fix my brew's installed binaries, but Claude Code should fix it internally for all users.

sovetski · 5 months ago

@Atcold no as I am on Ubuntu, my workaround is to use:

NPM := $(shell which npm 2>/dev/null || ls /home/USERNAMEHERE/.nvm/versions/node/*/bin/npm 2>/dev/null | tail -1)
PATH=$$(dirname $(NPM)):$$PATH $(NPM)
github-actions[bot] · 4 months ago

Closing for now — inactive for too long. Please open a new issue if this is still relevant.

sovetski · 4 months ago

This issue should be re-opened @bcherny @claude @chloeanT

github-actions[bot] · 4 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.