A foot gun in ripgrep
I adore ripgrep. It's fast, it's convenient, and I've never wanted a feature and found it missing.
But no software is perfect, and today ripgrep was the program causing problems.
Update
Andrew Gallant (the author of RipGrep) kindly pointed out on BlueSky that you can also address this by running a command in your repo:
echo '!/.github/' >> .rgignore
Thanks Andrew!
By default, ripgrep doesn't search everything. It checks your .gitignore
for example, which is wonderful when you don't want to be searching all of node_modules
. It also ignores hidden files and that's what bit me today.
See GitHub Actions are stored under .github/workflows/
, so when I removed a particular file and rg
'd through my whole codebase making sure it wasn't used anywhere I missed that it was used in some GitHub Actions.
Easily fixed, but how to make sure I don't get bit again?
We can search hidden files (but ignore .git/
) with
rg --hidden --glob=!.git/*
but that's a bit of a pain to type for a tool I use many times daily.
It turns out ripgrep does have a configuration file that you can activate by setting an environment variable (RIPGREP_CONFIG_PATH
).
After a bit of fussing with fish to get the variable set properly, I ended up with this in my shell config:
set -gx RIPGREP_CONFIG_PATH $HOME/.config/ripgreprc
and this in my ripgreprc
:
--hidden
--glob=!.git/*
And now I'm on to bigger and better (or at least different) problems.