Skip to content

Claude Code Launcher: Load shell profiles in Ghostty and Alacritty adapters, update icon#25639

Closed
jordiparra wants to merge 2 commits intoraycast:mainfrom
jordiparra:fix/load-shell-profiles
Closed

Claude Code Launcher: Load shell profiles in Ghostty and Alacritty adapters, update icon#25639
jordiparra wants to merge 2 commits intoraycast:mainfrom
jordiparra:fix/load-shell-profiles

Conversation

@jordiparra
Copy link

Summary

  • Load shell profiles in Ghostty and Alacritty adapters: When these terminals are launched via the macOS open command, shell profiles (~/.zshrc, ~/.zprofile, etc.) are not automatically sourced. This causes environment variables like ANTHROPIC_API_KEY to be missing, resulting in "Missing API key" errors when launching Claude Code. The fix explicitly sources common shell profile files before running Claude.
  • Update extension icon: Updated to match current Claude Code branding.

Details

The Ghostty and Alacritty adapters both use open -na <App> --args -e $SHELL -l -c <command> to launch. While -l requests a login shell, the -c flag causes the shell to run in non-interactive mode, skipping ~/.zshrc and 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:

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;

Test plan

  • Launch Claude Code via Ghostty with an API key set only in ~/.zshrc — verify it loads without "Missing API key" error
  • Launch Claude Code via Alacritty with the same setup — verify it works
  • Launch Claude Code via Terminal.app — verify no regression
  • Launch Claude Code via Warp — verify no regression

🤖 Generated with Claude Code

…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>
@raycastbot raycastbot added extension fix / improvement Label for PRs with extension's fix improvements extension: claude-code-launcher Issues related to the claude-code-launcher extension platform: macOS labels Feb 19, 2026
@raycastbot
Copy link
Collaborator

raycastbot commented Feb 19, 2026

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 commands
BRANCH="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 dev

We'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-apps
Copy link
Contributor

greptile-apps bot commented Feb 19, 2026

Greptile Summary

This 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 open command with the -c flag, shells run in non-interactive mode and skip loading ~/.zshrc and similar interactive profile files where environment variables like ANTHROPIC_API_KEY are typically defined.

Major Changes

  • Added shell profile sourcing (~/.zprofile, ~/.zshrc, ~/.bash_profile, ~/.bashrc, ~/.profile) before launching Claude in both Ghostty and Alacritty adapters
  • Updated extension icon to match current Claude Code branding
  • Terminal.app and Warp adapters remain unchanged (not affected by this issue)

Recommendations

  • Update CHANGELOG.md with these changes in the Unreleased section
  • Consider shell-specific profile sourcing rather than sourcing all profiles unconditionally to avoid potential conflicts between bash and zsh configurations

Confidence Score: 4/5

  • This PR is safe to merge with minor considerations about shell profile handling
  • The fix addresses a real user-facing bug that prevents Claude Code from launching. The implementation uses proper shell escaping and error suppression. Score is 4 rather than 5 because sourcing all shell profiles unconditionally could have unintended side effects if users have conflicting bash/zsh configurations, though this is unlikely in practice. CHANGELOG should also be updated.
  • CHANGELOG.md needs updating with these changes

Important Files Changed

Filename Overview
extensions/claude-code-launcher/assets/icon.png Icon updated to match current Claude Code branding, no issues found
extensions/claude-code-launcher/src/terminal-adapters/adapters/alacritty.ts Added shell profile sourcing before launching Claude to fix missing API key issue when launched via open -a command
extensions/claude-code-launcher/src/terminal-adapters/adapters/ghostty.ts Added shell profile sourcing before launching Claude to fix missing API key issue when launched via open -na command

Last reviewed commit: 0f1b7f0

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

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`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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`;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extension: claude-code-launcher Issues related to the claude-code-launcher extension extension fix / improvement Label for PRs with extension's fix improvements platform: macOS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants