gemini-cli icon indicating copy to clipboard operation
gemini-cli copied to clipboard

Run blocking/long running shell commands in background

Open codebam opened this issue 1 year ago • 24 comments

Describe the bug

I got gemini to write some code and then I was like "ok lets commit". Forgetting that I have gpg-agent and a provider set up for GPG so that I can sign commits with a yubikey. When it tried to commit gemini didn't know what to do, kept using tokens, and was very difficult to stop.

If you have your gpg-agent provider set to tty gemini receives a password prompt and doesn't give shell access to the user. For situations like this, or even sudo it would be nice if gemini could handle this nicely by giving you the ability to type into the shell command that is running.

Additional context

Diagnostic Information

  • CLI Version: 0.1.1
  • Git Commit: N/A
  • Operating System: linux v22.16.0
  • Sandbox Environment: no sandbox
  • Model Version: gemini-2.5-pro
  • Memory Usage: 177.7 MB

codebam avatar Jun 26 '25 01:06 codebam

Relevant internal bug: b/425804301 (run shell commands in a non-interactive tty)

markmcd avatar Jun 26 '25 04:06 markmcd

Duped another relevant issue where npm run dev hangs. It's not waiting for user input from the TTY but it is similar in concept (starting a web server)

markmcd avatar Jun 26 '25 05:06 markmcd

From closed dupe on hang of npm run dev:

Yeah. I was able to resolve. I had to change the version of tailwindcss to 3.4.17. Post that gemini was able to start the server.

jackwotherspoon avatar Jul 03 '25 20:07 jackwotherspoon

any workarounds for temporary guys? 😅

mrgoonie avatar Jul 05 '25 03:07 mrgoonie

From #3732:

Models running npm tests fail nearly 100% of the time from capturing the result of the test, instead they run indefinitely (I've left for 2 hours)

jackwotherspoon avatar Jul 10 '25 13:07 jackwotherspoon

does anyone found a workaround?

SaschaHeyer avatar Aug 05 '25 11:08 SaschaHeyer

does anyone found a workaround? Just try this ✌️ Image

OdinHoang03 avatar Aug 06 '25 14:08 OdinHoang03

same, it will be lovely if it auto detects the commands and run it in the background.

alih552 avatar Aug 31 '25 07:08 alih552

it seems it also does not react to new message.

weilinear avatar Sep 14 '25 05:09 weilinear

did anyone find a workaround for this . claude code handles this really well by providing a option to send the shell to background task ( via ctrl+b ) and read the shell output.

farseenmanekhan1232 avatar Oct 16 '25 10:10 farseenmanekhan1232

did anyone find a workaround for this . claude code handles this really well by providing a option to send the shell to background task ( via ctrl+b ) and read the shell output.

yes, use claude code

mrgoonie avatar Oct 16 '25 10:10 mrgoonie

We now have support for interactive shell commands You can use Ctrl+f to focus on shell commands that need are interactive and require input.

Going to update the title of this bug to now reflect the second ask which is adding support to run blocking or long running shell commands in the background. 👍

jackwotherspoon avatar Oct 20 '25 15:10 jackwotherspoon

We now have support for interactive shell commands You can use Ctrl+f to focus on shell commands that need are interactive and require input.

Going to update the title of this bug to now reflect the second ask which is adding support to run blocking or long running shell commands in the background. 👍

@jackwotherspoon Ctrl+f is not optimal its also the default to search stuff in vscode terminal which is not letting me use the interactive terminal in gemini please use something different or give us an option to set that

anushkrishnav avatar Oct 21 '25 23:10 anushkrishnav

@jackwotherspoon I want to make another point here. That in my previous try, not only npm run dev failed. But also node server.js

Which means, if an error was raised but no information on that error. Like no console.log() to explicitly print out the error. The Gemini will also stuck.

Since you merge issue here. I hope this problem can be addressed too, to avoid further debug.

XJTLUmedia avatar Nov 10 '25 14:11 XJTLUmedia

Let's say I run a flutter app. I want to keep the terminal open and in the background for the AI to keep in context.

DavidPluxia avatar Nov 19 '25 09:11 DavidPluxia

As people mentioned before, this issue pretty much makes gemini cli almost unusable.

My workaround was to ask it run services with nohup or setsid and dump the logs and look at the logs, but this ends up the agent getting stuck in restarting services loops when it needs to do so.

Any coding feedback loop will require the ability of the agent to work with an interactive shell making it probably the most crucial feature you guys might want to have a look to make this CLI agent work.

I think this is the real game changer feature that Claude code provides in the space. EDIT: forgot to mention an important bit. Interactive shell for user input must be a secondary option. The main option should be the background process. I say this cause you did implement this feature, it should definitely take a backseat to the more important functionality of background shell or it can end up still getting the agent stuck. Unless maybe you wanna run Gemini cli as a sys admin helper or something

I do realize good work went into the interactive shell bit, but it's not functional to solve this problems

Giusepperr avatar Nov 27 '25 23:11 Giusepperr

This is a feature request for the agent to run blocking commands in the background. The reported CLI version 0.1.1 is very old, so it needs retesting.

gemini-cli[bot] avatar May 11 '26 10:05 gemini-cli[bot]

The reported CLI version 0.1.1 is very old, so it needs retesting.

It's still actual on version 0.42.0.

ilyazub avatar May 15 '26 09:05 ilyazub

Please, this feature will be a game changer

abelopezpaniagua avatar May 16 '26 12:05 abelopezpaniagua

This report describes a bug where the agent hangs during interactive shell commands like GPG signing. Since this was reported on a very old version (0.1.1), please verify if this issue persists in the latest version (0.44.0).

gemini-cli[bot] avatar May 21 '26 21:05 gemini-cli[bot]