Shell Configuration Not Loaded in Claude Code Bash Execution

Status Fixed / completed
Maintainer reply ✓ Yes — wolffiex
Activity 8 comments · opened Jun 5, 2025 · closed Jun 5, 2025
💡 Likely answer: A maintainer (wolffiex, collaborator) responded on this thread — see the highlighted reply below.

Bug Description
Claude Code Bash tool doesn't load user shell configuration

The Bash tool executes commands without loading the user's shell configuration, even when their default shell is zsh. This creates a disconnect between the user's normal terminal experience and Claude
Code's execution environment.

Expected behavior:
Commands should have access to user-defined aliases, functions, and shell configuration.

Actual behavior:

  • echo $SHELL returns /bin/zsh
  • User aliases defined in ~/.zshrc.d/ return "command not found"
  • zsh -c 'source ~/.zshrc && type aliasname' works correctly, confirming the configuration is valid
  • Commands execute in a minimal environment without user customizations

Impact:
Users cannot use their normal shell aliases and functions, forcing them to use full command paths or work around their established workflows.

Suggested solutions:

  1. Source the user's shell configuration files (.zshrc, .bashrc) before command execution
  2. Add a setting to enable/disable loading user configuration
  3. Document that commands run in a minimal environment if this is intentional behavior

Environment:

  • macOS Darwin 24.5.0
  • Default shell: zsh
  • Shell configuration loads correctly in normal zsh sessions

Environment Info

  • Platform: macos
  • Terminal: tmux
  • Version: 1.0.11
  • Feedback ID: eabc0487-9a0a-4014-807f-a35ffd86f004

View original on GitHub ↗

8 Comments

wolffiex collaborator · 1 year ago

IIUC .zshrc.d is a convention but not a built-in behavior. Do you have a line like

for config in ~/.zshrc.d/*.zsh; do
    source "$config"
  done

in your .zshrc?

medecau · 1 year ago

@wolffiex , similar:

for file in ~/.zshrc.d/*.zsh; do
source $file
done

wolffiex collaborator · 1 year ago

it is likely that there is an error in your .zshrc that is causing the
snapshot generation to fail before it reaches that point. can you maybe
bisect or move up this block until you find the command that may be causing
problems for claude?

On Thu, Jun 5, 2025 at 11:56 AM medecau @.***> wrote:

medecau left a comment (anthropics/claude-code#1630) <https://github.com/anthropics/claude-code/issues/1630#issuecomment-2945711856> @wolffiex <https://github.com/wolffiex> , similar: for file in ~/.zshrc.d/.zsh; do source $file done — Reply to this email directly, view it on GitHub <https://github.com/anthropics/claude-code/issues/1630#issuecomment-2945711856>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/AABUJ7DPI66R3OXTOC643CL3CCHFJAVCNFSM6AAAAAB6UVTE6GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDSNBVG4YTCOBVGY> . You are receiving this because you were mentioned.Message ID: @.**>
medecau · 1 year ago

@wolffiex you were right, it was something in the zsh config
i was also hitting the wrong claude executable as i initially installed globally and recently moved to local
while i had claude working on fixing that i fixed a few other things that got squashed so bisecting might not yield any useful signal anymore

thank you for your replies it did help guide my attention and persist on getting zsh config in better shape

wolffiex collaborator · 1 year ago

this is great Claude Code use case! glad you were able to resolve it

Liu-Eroteme · 1 year ago

Wait.. Is this supposed to work now, or not? I just ran into the same issue, but plain bash & a .bashrc file, not zsh - i need my aliases

medecau · 1 year ago

@Liu-Eroteme this is most likely an issue with your environment or the .bashrc file.
try starting claude on your home directory, switch to plan mode (shift + tab), then introduce your issue to claude in clear terms. mention the word "ultrathink" in the prompt and ask for a root cause analysis. if the plan looks good let it implement the fixes before restarting the terminal.

github-actions[bot] · 1 year 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.