Broken SearchText tool when RIPGREP_CONFIG_PATH is set due to bundled ripgrep v13.0.0
What happened?
Bug: SearchText tool can fail when $RIPGREP_CONFIG_PATH is set
gemini's SearchText tool consistently fails on my machine, due to my terminal having $RIPGREP_CONFIG_PATH set and pointing to a file containing the following:
--threads=4
When SearchText is triggered from a regular prompt (e.g. "where in this codebase can I find …"), it invokes rg (ripgrep), which fails with the following error:
✓ SearchText 'chapter' within ./
Error: ripgrep exited with code 2: error: The argument '--threads <NUM>' requires 1 values, but 2 were provided
USAGE:
rg [OPTIONS] PATTERN [PATH ...]
rg [OPTIONS] -e PATTERN ... [PATH ...]
rg [OPTIONS] -f PATTERNFILE ... [PATH ...]
rg [OPTIONS] --files [PATH ...]
rg [OPTIONS] --type-list
command | rg [OPTIONS] PATTERN
rg [OPTIONS] --help
rg [OPTIONS] --version
For more information try --help
Explanation
gemini passes a number of arguments to rg, including --threads 4 just before the path to search: https://github.com/google-gemini/gemini-cli/blob/57c7b9ccced5df56e9cc1673a4e6c98bb3c82271/packages/core/src/tools/ripGrep.ts#L392-L393
If set, rg itself will read the file at $RIPGREP_CONFIG_PATH and combine its contents with the CLI args, which leads to both --threads=4 and --threads 4 being part of rg's execution parameters.
With the bundled binary ~/.gemini/tmp/bin/rg at version 13.0.0, this combination leads to rg failing with the error shown above.
Steps to reproduce
Create a ripgrep config file (e.g., ~/.ripgreprc) containing the following:
--threads=4
Export the environment variable:
export RIPGREP_CONFIG_PATH=~/.ripgreprc
Run gemini in any repo, and ask it to search for some text.
Manual repro
The failure can also be reproduced manually:
~/.gemini/tmp/bin/rg --regexp search-term --threads=4 --threads 4 ./
What did you expect to happen?
I expected SearchTool to be able to use rg without issues and find the text I was asking for.
Client information
Client Information: v0.20.2
Run gemini to enter the interactive CLI, then run the /about command.
> /about
CLI Version 0.20.2
Git Commit af894e468
Model auto
Sandbox no sandbox
OS darwin
Auth Method OAuth
I've observed the same behavior on the most recent nightly, v0.21.0-nightly.20251213.977248e09.
Login information
No response
Anything else we need to know?
No other reports
I searched for issues mentioning RIPGREP_CONFIG_PATH, but none existed before this one.
Working version
I have rg installed on my system via Homebrew, at version 15.1.0. It does not reproduce this issue, and performs the search as expected.
Workaround
If you have a version of rg more recent than 13.0.0, you can replace ~/.gemini/tmp/bin/rg with your copy:
mv ~/.gemini/tmp/bin/rg ~/.gemini/tmp/bin/rg.orig
cp $(which rg) ~/.gemini/tmp/bin/rg
Suggested fix
I would suggest using a more recent version of ripgrep. From what I can tell, the repo for the rg binary and its version are configured here: https://github.com/google-gemini/gemini-cli/blob/57c7b9ccced5df56e9cc1673a4e6c98bb3c82271/third_party/get-ripgrep/src/downloadRipGrep.js#L24-L25
That repo published a release with rg binaries for version 15.0.0 on October 21.