Claude Code Launcher: Load shell profiles in Ghostty and Alacritty adapters, update icon#25639
Claude Code Launcher: Load shell profiles in Ghostty and Alacritty adapters, update icon#25639jordiparra wants to merge 2 commits intoraycast:mainfrom
Conversation
…apters, update icon - Source shell profiles (~/.zprofile, ~/.zshrc, ~/.bash_profile, ~/.bashrc, ~/.profile) in Ghostty and Alacritty adapters before launching Claude Code - Update extension icon to match Claude Code branding When Ghostty or Alacritty are launched via macOS 'open' command with '-c' (command mode), the shell runs non-interactively and skips loading profile files like ~/.zshrc. This causes environment variables (e.g. ANTHROPIC_API_KEY) to be unavailable, resulting in "Missing API key" errors. The fix sources all common profile files with error suppression (2>/dev/null) so missing files are silently ignored. Terminal.app and Warp are not affected as they handle shell initialization differently. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Thank you for your first contribution! 🎉 🔔 @stephendolan @ridemountainpig you might want to have a look. You can use this guide to learn how to check out the Pull Request locally in order to test it. 📋 Quick checkout commandsBRANCH="fix/load-shell-profiles"
FORK_URL="https://github.com/jordiparra/extensions.git"
EXTENSION_NAME="claude-code-launcher"
REPO_NAME="extensions"
git clone -n --depth=1 --filter=tree:0 -b $BRANCH $FORK_URL
cd $REPO_NAME
git sparse-checkout set --no-cone "extensions/$EXTENSION_NAME"
git checkout
cd "extensions/$EXTENSION_NAME"
npm install && npm run devWe're currently experiencing a high volume of incoming requests. As a result, the initial review may take up to 10-15 business days. |
- Resize icon to 512x512 pixels (required by Raycast) - Add changelog entries for shell profile loading fix and icon update
Greptile SummaryThis PR fixes a critical bug where Claude Code would fail to launch in Ghostty and Alacritty terminals with "Missing API key" errors. The root cause is that when terminals are launched via macOS Major Changes
Recommendations
Confidence Score: 4/5
Important Files Changed
Last reviewed commit: 0f1b7f0 |
| const command = `cd ${this.shellEscape(directory)} && clear && claude ; exec ${userShell} -l`; | ||
| // Source shell profiles to load environment variables (including API keys) | ||
| // before running claude, since 'open -a' with '-c' skips interactive profile loading | ||
| const command = `source ~/.zprofile 2>/dev/null; source ~/.zshrc 2>/dev/null; source ~/.bash_profile 2>/dev/null; source ~/.bashrc 2>/dev/null; source ~/.profile 2>/dev/null; cd ${this.shellEscape(directory)} && clear && claude ; exec ${userShell} -l`; |
There was a problem hiding this comment.
Sourcing all profile files unconditionally may have unintended side effects. Consider checking $SHELL environment variable and only sourcing profiles for the detected shell (zsh profiles for zsh, bash profiles for bash). Currently sourcing both bash and zsh profiles regardless of shell type could cause conflicts.
| // 3. clear the screen for a clean start | ||
| // 4. launch claude CLI | ||
| // 5. exec the shell to replace the process | ||
| const command = `source ~/.zprofile 2>/dev/null; source ~/.zshrc 2>/dev/null; source ~/.bash_profile 2>/dev/null; source ~/.bashrc 2>/dev/null; source ~/.profile 2>/dev/null; cd ${this.shellEscape(directory)} && clear && claude ; exec ${userShell} -l`; |
There was a problem hiding this comment.
Sourcing all profile files unconditionally may have unintended side effects. Consider checking $SHELL environment variable and only sourcing profiles for the detected shell (zsh profiles for zsh, bash profiles for bash). Currently sourcing both bash and zsh profiles regardless of shell type could cause conflicts.
Summary
opencommand, shell profiles (~/.zshrc,~/.zprofile, etc.) are not automatically sourced. This causes environment variables likeANTHROPIC_API_KEYto be missing, resulting in "Missing API key" errors when launching Claude Code. The fix explicitly sources common shell profile files before running Claude.Details
The Ghostty and Alacritty adapters both use
open -na <App> --args -e $SHELL -l -c <command>to launch. While-lrequests a login shell, the-cflag causes the shell to run in non-interactive mode, skipping~/.zshrcand similar interactive profile files where users commonly set environment variables.Terminal.app and Warp are not affected — Terminal.app opens a full login+interactive shell via AppleScript, and Warp manages its own shell environment through launch configurations.
The fix sources all common profile files with error suppression (
2>/dev/null) so missing files are silently ignored:Test plan
~/.zshrc— verify it loads without "Missing API key" error🤖 Generated with Claude Code