Skip to content

fix: rg hanging forever when run in bash, waiting for stdin - #3103

Merged
rekram1-node merged 4 commits into
anomalyco:devfrom
remorses:fix-rg-hang
Oct 12, 2025
Merged

rekram1-node merged 4 commits into
anomalyco:devfrom
remorses:fix-rg-hang

Conversation

@remorses

Copy link
Copy Markdown
Contributor

Pass ignore to stdin so that rg does not wait for stdin input. This probably fixes other commands hanging

Fix #3089

Copilot AI review requested due to automatic review settings October 11, 2025 16:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes an issue where rg (ripgrep) and potentially other commands would hang indefinitely waiting for stdin input. The fix involves switching from exec to spawn and explicitly ignoring stdin by setting the stdio configuration.

  • Replaced exec with spawn for better process control
  • Added stdio: ["ignore", "pipe", "pipe"] to explicitly ignore stdin while preserving stdout and stderr pipes

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread packages/opencode/src/tool/bash.ts Resolved
@remorses remorses changed the title Fix rg hanging forever, waiting for stdin Fix rg hanging forever when run in bash, waiting for stdin Oct 11, 2025
Comment thread packages/opencode/src/tool/bash.ts Outdated
@@ -146,9 +145,11 @@ export const BashTool = Tool.define("bash", {
})
}

const process = exec(params.command, {
const process = spawn(params.command, {
shell: 'bash',

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

will this break windows?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It will work if the user has bash in PATH

I know Git for windows also installs Git Bash so we should use that if the user hasn't bash in path

This is what Claude Code does: if there is no global bash in Windows try to use C:\Program Files\Git\bin\bash.exe or the env variable CLAUDE_CODE_GIT_BASH_PATH

This should be done in a separate PR

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I think leaving it with just shell: true makes sense for now to avoid any breaking changes

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

it preserves existing behavior and fixes issue

remorses and others added 3 commits October 11, 2025 23:05
This reverts commit e205053190d2de9e879d913bba4348e46337ae61.
@rekram1-node rekram1-node changed the title Fix rg hanging forever when run in bash, waiting for stdin fix: rg hanging forever when run in bash, waiting for stdin Oct 12, 2025
@rekram1-node
rekram1-node merged commit b4171aa into anomalyco:dev Oct 12, 2025
@jscheel

jscheel commented Oct 13, 2025

Copy link
Copy Markdown
Contributor

This is still an issue. File references cause opencode to use 100% of a core indefinitely, and the search will never return a result. Ripgrep work fine when run from the shell.

@rekram1-node

Copy link
Copy Markdown
Collaborator

That one is slightly different but we will check it out thank you for raising

@rekram1-node

Copy link
Copy Markdown
Collaborator

@jscheel can you confirm that you aren't working in a python project and that ripgrep is the actual issue?

Because I have seen some issues like that specifically for python projects due to the lsp server

@jscheel

jscheel commented Oct 13, 2025 via email

Copy link
Copy Markdown
Contributor

@rekram1-node

Copy link
Copy Markdown
Collaborator

@jscheel to fix this add the following to your opencode.json (long term we need to fix something but for short term usability this may be good):

{
  "lsp": {
     "pyright": {
         "disabled": true
      }
  }
}

@jscheel

jscheel commented Oct 13, 2025 •

Copy link
Copy Markdown
Contributor

@rekram1-node 🫡 will give it a try. Thanks! I can help debug anything if necessary.

@remorses

remorses commented Oct 13, 2025 •

Copy link
Copy Markdown
Contributor Author

@rekram1-node let's just disable LSP by default. It causes so many opencode issues and it must already have churned so many users. I am able to use opencode just because I disabled it

@rekram1-node

Copy link
Copy Markdown
Collaborator

@remorses hm ultimately the decision isn't up to me but at my previous job I literally couldn't get an agent to write good java (in sufficiently large codebase) without the lsp feedback it would always have some error

but I get what your point is I saw the change my mind in discord too haha

@jscheel

jscheel commented Oct 13, 2025 via email •

Copy link
Copy Markdown
Contributor

@rekram1-node

Copy link
Copy Markdown
Collaborator

@jscheel if you try the latest version this has been fixed, you should be able to remove that disable now

@jscheel

jscheel commented Oct 13, 2025

Copy link
Copy Markdown
Contributor

@rekram1-node hah, love it. Bumping to 0.15.1 now, will give it a run.

Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request May 5, 2026
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
meSingh pushed a commit to meSingh/opencode that referenced this pull request Sep 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rg hangs indefinitely in 0.14.7 in a linux/amd64 container; works on 0.14.6

4 participants