Gemini CLI Crash: Shell Command Confirmation Bug
Encountering a crash in the Gemini CLI when it tries to confirm a shell command? You're not alone! Many users have reported a frustrating issue where the Gemini Command Line Interface (CLI) abruptly exits whenever it needs to ask for your permission to run a shell command. This isn't just a minor glitch; it completely cripples the CLI's ability to perform essential tasks that rely on executing commands, like managing code with Git, installing dependencies with Composer, or running tests. Let's dive deep into this problem, understand its intricacies, and explore potential workarounds and solutions.
Understanding the run_shell_command Crash
The core of the problem lies within the run_shell_command tool. When the Gemini CLI, powered by models like gemini-3-pro-preview, needs to execute a command on your system – for instance, checking your Python version with python3 --version – it's designed to pause and ask for your explicit confirmation. This is a crucial security feature. However, in specific environments, this confirmation step causes the entire CLI application to terminate unexpectedly. Instead of waiting for your input (like selecting '1. Yes, allow once' or '3. No, suggest changes'), the CLI just quits, dropping you back to your regular shell prompt. This behavior has been observed on Linux systems when connected via SSH, using Gemini CLI version 0.19.1. The terminal type, such as xterm-256color or screen over SSH, also seems to be a factor. It's important to note that other tool calls, such as list_directory, read_file, and write_file, function correctly, indicating the issue is specific to the run_shell_command execution flow.
The User Experience of the Crash
Imagine you're working on a project, and you ask Gemini to perform a task that requires it to interact with your system's command line. For example, you might ask, "What's the current Git branch?" or "Install the latest dependencies." The AI understands and prepares to execute a command like git status or composer install. At this point, the Gemini CLI should present you with a clear prompt, usually within a visually distinct box, asking something like: Allow execution of: 'git status'? followed by options to confirm or deny. The problem is, as soon as this prompt appears on your screen, the CLI crashes. You see the prompt for a split second, and then – poof! – you're back at your command line, with no explanation and no chance to interact. The console output from a user experiencing this might look something like this:
1 > yes but if you run py i think it quits
2
3 Responding with gemini-3-pro-preview
4 ✦ I understand. You suspect that specifically triggering a shell command (like running Python) is what causes the crash/quit.
5
6 Let's test this safely with a very simple, instant command. I will attempt to check the Python version.
7
8 If this crashes/quits immediately without letting me approve it, then we know the issue is specifically with the run_shell_command
tool
9 in your environment.
10 ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
───╮
11 │ ? Shell python3 --version [current working directory /home/blesta/public_html/plugins/blesta_qbo_sync] ← │
12 │
13 │ python3 --version
14 │
15 │ Allow execution of: 'python3'?
16 │
17 │ ● 1. Yes, allow once
18 │ 2. Yes, allow always ...
19 │ 3. No, suggest changes (esc)
20 │
21 ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
───╯
22 ⠏ Waiting for user confirmation...
23
24 Using: 1 GEMINI.md file
25 ~/.../plugins/blesta_qbo_sync (master*) no sandbox (see /docs) auto (99% context
left)
26 [blesta@blesta blesta_qbo_sync]$
Notice how after the confirmation prompt is displayed, the next line is the user's shell prompt ([blesta@blesta blesta_qbo_sync]$), indicating the Gemini CLI process has terminated. The Waiting for user confirmation... message is left hanging, and the user never gets to input '1', '2', or '3'. This issue is particularly disruptive because it prevents any automation or task execution that relies on the AI's ability to interact with the shell.
Why is This Happening? The SSH Connection Conundrum
Several pieces of information point towards the interaction between the Gemini CLI, the run_shell_command tool, and SSH connections as the likely culprit. The fact that other tool calls, which don't involve executing arbitrary commands, work perfectly fine suggests the issue isn't a general instability of the CLI or the SSH connection itself. The problem specifically arises when the CLI attempts to render and await input for the shell command confirmation prompt. This prompt relies on interactive terminal features. When you're connected via SSH, especially to servers where terminal emulation might differ from your local setup, or when using terminal multiplexers like screen, there can be subtle differences in how input and output are handled. It's possible that the specific way the Gemini CLI tries to manage the interactive prompt for run_shell_command conflicts with the terminal capabilities or event handling mechanisms present in an SSH session. This conflict could be leading to an unhandled exception or a signal that causes the CLI process to exit prematurely. The CLI might be sending control signals or expecting input in a way that the SSH terminal doesn't correctly interpret, leading to the crash. Developers working with the Gemini CLI are actively investigating this, likely trying to pinpoint the exact library or terminal interaction causing the breakage over SSH.
Environment Details and Reproducibility
To help diagnose and fix this bug, precise environment details are crucial. The issue has been reliably reproduced under the following conditions:
- Operating System: Linux (specific distribution details might vary, but the core issue seems OS-agnostic within Linux environments).
- Connection Type: SSH (this is a key factor, as local terminal use might not exhibit the same behavior).
- Gemini CLI Version: 0.19.1, specifically with Git commit hash
6169ef04b. - Terminal: Standard SSH terminal clients (e.g.,
xterm-256color,screenortmuxrunning over SSH). - Working Directory: The issue appears to occur regardless of the current directory the CLI is operating within.
This consistency in reproduction across different users experiencing the problem makes it a valuable bug to tackle. The team behind the Gemini CLI has been provided with this information, and they are likely using it to replicate the issue in their testing environments. The summary provided by the user, stating that "if you run py i think it quits," directly points to the execution of shell commands as the trigger. The detailed output further confirms that the crash happens after the command is prepared and during the prompt display, before any user interaction is possible. This information is critical for developers to trace the execution flow and identify the precise line of code or interaction that fails.
Impact on Functionality: A Major Roadblock
The inability to execute shell commands via the Gemini CLI is a significant impediment to its usefulness, especially for developers and system administrators. The run_shell_command functionality is not a niche feature; it's fundamental for a vast array of tasks. Imagine trying to use an AI assistant for coding tasks when it can't even check your code's syntax, run build scripts, or manage your project's dependencies. This bug effectively disables the CLI for any scenario that requires interaction with the operating system's command line. Tasks like:
- Version Control: Running
git status,git pull,git commit. - Dependency Management: Executing
npm install,pip install,composer update. - Build and Deployment: Running
make,docker build, deployment scripts. - System Information: Gathering details about the system, checking service status.
- File Operations: Moving, copying, or deleting files using shell commands (though
read_file,write_filework, more complex operations often require shell execution).
When the AI suggests a command and the CLI crashes before you can even approve it, the entire workflow is broken. You're forced to manually copy the command and execute it yourself, defeating the purpose of having an AI-powered CLI. The impact is amplified when using the CLI remotely via SSH, a common practice for developers managing servers or working on cloud environments. The crash essentially turns the powerful Gemini CLI into a limited chatbot incapable of performing critical system-level actions, significantly reducing its value proposition.
Potential Workarounds and Future Solutions
While a permanent fix is being worked on, users facing this run_shell_command crash might explore a few avenues. Firstly, if possible, try running the Gemini CLI without SSH. If the crash doesn't occur in a local terminal, it strongly reinforces the SSH-specific nature of the bug. This could allow you to use the CLI for tasks that don't require remote command execution. Secondly, check for updates to the Gemini CLI. The developers are actively working on issues, and newer versions might contain a fix. Keep an eye on the official Gemini CLI GitHub repository for release notes and updates. It's also possible that specific terminal configurations or SSH client settings could be playing a role. Experimenting with different terminal emulators or disabling certain advanced features in your SSH client might, in rare cases, bypass the issue, though this is less likely to be a robust solution. The most effective approach, however, remains reporting the issue clearly, as the user has done here, and awaiting an official patch. The team's ability to fix this depends on understanding the root cause, which seems to be tied to interactive terminal handling over SSH. The fact that the bug report URL provided by the CLI initially resulted in an HTTP 400 error highlights the importance of using the correct channels, like the GitHub issues page, for reporting bugs. This ensures that the development team receives the necessary information to investigate and resolve the problem effectively. Stay tuned to the official Gemini CLI GitHub repository for updates and potential fixes for this critical bug.