[BUG] PATH exports in shell config files ignored by Claude Code VS Code extension
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'
11 Comments
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:Option 2: Move PATH exports to a login profile
Put your PATH modifications in
~/.bash_profileor~/.profileinstead of~/.bashrc. These are sourced by login shells, which VSCode can be configured to use:The
-lflag makes it a login shell, which sources~/.bash_profile.Option 3: Source bashrc from bash_profile
Add this to
~/.bash_profile: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 (
claudein a terminal) doesn't have this problem because your terminal is an interactive login shell that already sourced.bashrc.Thanks, @yurukusa, for your answer.
I did update VSCode settings, but it's not working.
My path
What Claude sees:
Ah, I think I figured.
VS Code does source
~/.profile.My
~/.profileopens withsource $HOME/.bashrc, and therefore it gets my aliases.Yet,
~/.bashrcdoes 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…
Same problem here, @yurukusa I am not sure that it is "VS Code problem", I am also using GitHub Copilot and it works perfectly
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
~/.bashrcand~/.profile||
PATH| VS Code's process environment at launch |These are captured separately.
export PATH=...statements in.bashrcor.profileare ignored for the snapshot's PATH — it comes from wherever VS Code itself inherited its PATH (typicallypath_helperreading/etc/paths+/etc/paths.d/).Why
brew shellenvdoesn't helpThe
eval "$(brew shellenv)"block internally callspath_helper -s, which resets PATH from scratch based on/etc/pathsand/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.osxdoesn't helpThat VSCode setting only affects the integrated terminal, not the environment inherited by the Claude Code extension process.
Broken symlink causes total failure
If
~/.bashrcis a broken symlink (e.g. the target file was renamed), snapshot generation fails entirely — not even~/.profilealiases are captured. The snapshot requires~/.bashrcto be sourceable.What actually works
The only reliable fix is registering Homebrew at the
path_helperlevel: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 thatterminal.integrated.env.osxdoes not affect the Bash tool, and that/etc/paths.d/is the correct fix on macOS.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"
@sovetski, did my workaround worked? I managed to fix my brew's installed binaries, but Claude Code should fix it internally for all users.
@Atcold no as I am on Ubuntu, my workaround is to use:
Closing for now — inactive for too long. Please open a new issue if this is still relevant.
This issue should be re-opened @bcherny @claude @chloeanT
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.