Shell Configuration Not Loaded in Claude Code Bash Execution

Resolved 💬 8 comments Opened Jun 5, 2025 by medecau Closed Jun 5, 2025

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 ↗

This issue has 8 comments on GitHub. Read the full discussion on GitHub ↗