Ripgrep 15.0.0
68 points by telemachus
68 points by telemachus
Ripgrep felt like such an innovation in the field of tools that were already available for decades; until it wasn't.
The behaviour with using config files of other completely unrelated programs (.gitignore and now jj too) was not only non-logical to me, it failed my tasks couple of times.
The defaults will always fail someone. When designing you have to assume a common use case and base your defaults on that. For ag and rg ignoring the .gitignore by default works for me and many others. When it doesn't you just pass -U to ag, which takes no time to learn.
While I agree, I also feel like the defaults should not exclude files. Excluding them is basically the "fast" variant that may also miss matches while the default behaviour should be to find everything even if it's slower.
That's certainly the right thing in principle. On the other hand, I've performed thousands of ripgrep searches and never wanted to include the files it excluded by default, and excluding those files makes it 10x faster than grep which is enough to feel like a qualitative rather than quantitative advantage.
I like that the default excludes files because I use rg to search source code, so I view hits on output objects as false positives.
Yet that can be (globally) configured in an .rgrc file, which is probably worth the trouble considering how handy rg is overall.
To be sure, .rgrc is a user supplied filename.  From the rg(1) manpage:
ripgrep will look for a single configuration file if and only if the RIPGREP_CONFIG_PATH environment variable is set and is non-empty.
An intuitive UX would have the defaults be the other way around in my opinion.
FWIW I think ugrep works that way.
Well, ugrep has ugrep, the which searches everything, and ug which has different defaults, --config --pretty --sort.
What I mean is, as far as I understand, neither of those ugrep commands ignore things from a git ignore file unless you use an explicit option or config to do so.
I think the behavior matches mariusor's notion of intuitive UX.
My biggest gripe is ripgrep won't search files prefixed with a . by default.  Especially confounding when trying to locate configuration lines in one's homedir, since it won't search shell startup scripts like .bashrc without encouragement.  (-. flag exists for this use case.)
Agree, I feel like using gitignore is a terrible default setting. Just because a file is ignored from VCS doesn’t mean you don’t want to grep it, it’s just not the same thing. I guess it started from a good intention, but this idea completely failed me. It doesn’t help that I can never remember the flag to unignore gitignore, and every time I Google it I only find threads discussing the feature but not the actual flag to use.
FWIW, I agree with you that the default behavior is wrong (well, "wrong" for me); being ignored in VCS is orthogonal to being excluded from search.
That said, it in case it helps, the flags I use are
-uu:   searches for all but binary files-uuu:   searches for all filesThankfully easy to type and not too hard to remember...
(There is also -u, which searches for all files except binary and except files starting with a dot .. I don't use this too much.)
The problem is that it's not just binary files: sometimes I have third_party dependencies in my tree and I want to ignore those but I don't want to ignore e.g. generated source files of my own project.
Maybe there's no way out here except maintain a separate file and use --ignore-file.
You might have luck with -g’!3rdparty’ (on mobile so I can’t test), if you want to exclude stuff under a folder called 3rd party.  IIRC, -g is glob and the exclamation mark inverts the glob.
Respectfully… how is ripgrep supposed to know the difference between third-party dependencies and generated source files? This sounds like exactly the use case that --ignore-file was meant for.
I'm not expecting it to know the difference but I was more thinking if there was a standard way to tell it without needing to specifying --ignore-file every time (or setting it in my config file which means anyone else i share the repo with would also need to know to put the same in their config file). .ignore I did know about but that's also used by other tools whereas I want something quite specific to ripgrep.
However my comment set me searching on ripgrep's man page and I found there's also .rgignore which I think is exactly what I was looking for!
The problem is that there are two kinds of ignores, build artifacts and local configuration. Most of the time, I want to ignore the former, but not the latter. Gitignore et al. do not distinguish the two things.
Tangential but I love the large major number here. Helps give me confidence that the version number is actually semver instead of “semver”
I don’t like it when major versions are basically for marketing (even though I participate in projects that do it).