Uses 'SearchText' on all files even with respectGitIgnore=true
What happened?
I was asking gemini-cli to replace usages of Regex::new() with a macro.
It would use the SearchText tool, but instead of only searching through the project files, it also searched through artifacts which are gitignored.
Is it expected that SearchText is searching also in gitignored files?
What did you expect to happen?
The SearchText should only search in non-ignored files, or gemini should use it more cleverly, e.g. only search in .rs files.
Client information
$ gemini /about
╭───────────────────────────────────────────────────────╮
│ │
│ About Gemini CLI │
│ │
│ CLI Version 0.1.21 │
│ Git Commit 055fe46d │
│ Model gemini-2.5-pro │
│ Sandbox no sandbox │
│ OS linux │
│ Auth Method gemini-api-key │
│ │
╰───────────────────────────────────────────────────────╯
Login information
│ Auth Method gemini-api-key
Anything else we need to know?
No response
We should respect the gitIgnore and geminiIgnore for SearchText. Likely we should do this by filtering the results from the underlying grep or ripgrep commands as it is likely not feasible to fully enforce them within those tools. If implemented as a post process this should be a fairly simple and robust fix.
Just to add that I had the feeling SearchText was very slow for me, probably also because it searched through a lot of big files (maybe even binary files), that are gitignored.
From that perspective it would be better to only search through non-ignored files, instead of filter out results later.
I would like to work on this. Could you please assign it to me?
Will be looking into the issue. Thanks
@njam ripGrep (rg) by default takes .gitignore into account and also excludes binary files. Does your system have ripGrep installed, if not it this a git repo. The reason I am asking these questions is to first understand which search strategy gemini is using in your case.
@gsehgal hm, yes it was definitely a git repo, and I do have rg installed.
@njam so would it be safe to say that cli end up using git grel (strategy 1) , because git grep would ignore binary files by default, the only thing won't include is .geminiexclude?
Also, could you please share which OS you were running gemini cli on?
@njam have provided a fix where in Linux environment which don't have ripGrep installed the cli ends up using strategy 3 and does not use the 1st 2 strategy.
If you are running on Linux then you try the latest fix. Will update the ticket once the latest fix has been rolled out or if you want you can try the nightly version
Hi @njam , please let me know if search performance has improved, as the fix has been rolled out.
@gsehgal thanks a lot. Sorry, I'm currently not using Gemini-cli. Feel free to close it, thanks.
@njam
Understood. Thanks for letting us know about your current usage of the Gemini CLI. I'll go ahead and close this out.
Should you decide to use it again in the future, please don't hesitate to reach out to us for any assistance—we'll be happy to help!