gemini-cli - 💡(How to fix) Fix Support customizing execution shell (e.g. to zsh) in Unix-like environments

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Currently, in packages/core/src/utils/shell-utils.ts, getShellConfiguration() hardcodes the execution shell to bash for all Unix-like platforms (macOS, Linux):

export function getShellConfiguration(): ShellConfiguration {
  ...
  // Unix-like systems (Linux, macOS)
  return { executable: 'bash', argsPrefix: ['-c'], shell: 'bash' };
}

Because of this hardcoding, the CLI and agent cannot run commands using the user's preferred shell such as zsh or fish.

For macOS users, where zsh is the default system shell, key configurations (e.g., Homebrew paths, custom environment variables, Node version managers) are typically loaded inside ~/.zshrc. Spawning commands via a hardcoded bash environment prevents these settings from being inherited naturally, resulting in commands not being found or execution failures during agent runs.

Root Cause

Because of this hardcoding, the CLI and agent cannot run commands using the user's preferred shell such as zsh or fish.

Code Example

export function getShellConfiguration(): ShellConfiguration {
  ...
  // Unix-like systems (Linux, macOS)
  return { executable: 'bash', argsPrefix: ['-c'], shell: 'bash' };
}

---

{
     "terminal.integrated.defaultProfile.osx": "zsh"
   }
RAW_BUFFERClick to expand / collapse

Description

Currently, in packages/core/src/utils/shell-utils.ts, getShellConfiguration() hardcodes the execution shell to bash for all Unix-like platforms (macOS, Linux):

export function getShellConfiguration(): ShellConfiguration {
  ...
  // Unix-like systems (Linux, macOS)
  return { executable: 'bash', argsPrefix: ['-c'], shell: 'bash' };
}

Because of this hardcoding, the CLI and agent cannot run commands using the user's preferred shell such as zsh or fish.

For macOS users, where zsh is the default system shell, key configurations (e.g., Homebrew paths, custom environment variables, Node version managers) are typically loaded inside ~/.zshrc. Spawning commands via a hardcoded bash environment prevents these settings from being inherited naturally, resulting in commands not being found or execution failures during agent runs.

Proposed Solutions

  1. Leverage $SHELL Environment Variable: Detect the current shell from process.env.SHELL first. If it points to an installed system shell (like /bin/zsh), use it to resolve the execution configuration.
  2. Add a Configuration Setting: Allow users to specify the preferred shell in settings.json, matching VS Code styles:
    {
      "terminal.integrated.defaultProfile.osx": "zsh"
    }

Client Environment

  • OS: macOS (Darwin)

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING