Shell Configuration Not Loaded in Claude Code Bash Execution
Status Fixed / completed
Maintainer reply ✓ Yes — wolffiex
Workaround ✓ Mentioned in description ↑
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:
- Source the user's shell configuration files (.zshrc, .bashrc) before command execution
- Add a setting to enable/disable loading user configuration
- 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
8 Comments
IIUC
.zshrc.dis a convention but not a built-in behavior. Do you have a line likein your .zshrc?
@wolffiex , similar:
for file in ~/.zshrc.d/*.zsh; do
source $file
done
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:
@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
this is great Claude Code use case! glad you were able to resolve it
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
@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.
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.