Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I was using ripgrep once and it had a bug that led me downa terrifying rabbit hole - I can't recall what it was but it involved not being able to find text that absolutely should have been there.

Eventually I was considering rebuilding the machine completely but for some reason after a very long time digging deep into the rabbit hole I tried plain old grep and there was the data exactly where it should have been.

So it's such a vague story but it was a while back - I don't remember the specifics but I sure recall the panic.



I agree, it's a great tool with a catastrophically wrong default that silently and unpredictably catches people off-guard. I've tried using ripgrep many times but have been burnt too many times and can never trust its search to be comprehensive. It absolutely fails to find important stuff, and I can rarely predict whether the files it's going to skip intersect with my files of interest. And at this point I'm too burnt to care to pass flags to stop it from doing that. Which basically means I always run grep unless I know the number of matches beforehand and it's too large a directory to wait a few seconds for, in which case I run grep after rg fails to find it.

If it actually matched grep's contract with opt-in differences that'd be a gamechanger and actually let it become the default for people, but that ship seems to have sailed.


idk if this was your issue but I’m posting this because it’s not obvious (especially the default behavior):

  rg      : Searches git tracked files
  rg -u   : Includes .gitignored files
  rg -uu  : Includes .gitignored + hidden files
  rg -uuu : Includes .gitignored + hidden + binary files


Was it confirmed to be a bug?

Sometimes I forget that some of the config files I have for CI in a project are under a dot directory, and therefore ignored by rg by default, so I have to repeat the search giving the path to that config files subdirectory if I want to see the results that are under that one (or use some extra flags for rg to not ignore dot directories other than .git)


Sorry I don't recall exactly but I don't think it was anything special like a hidden or binary file.

I still use it but Ive never trusted it fully since then I double check.


Was the file in a .gitignore by any chance? I've got my home folder in git to keep track of dot/config files and that always catches me out. Really dislike it defaulting to that ignoring files that are ignored by git.


> Really dislike it defaulting to that ignoring files that are ignored by git.

It's the reason I started using it. Got sick of grep returning results from node_modules etc.


You started using it because it had that capability I imagine, not because it is the default. You could easily just alias a command with the right flag if the capability was opt-in.


No, because it was default.

> You could easily just alias a command with the right flag if the capability was opt-in.

I tried a search to make grep ignore .gitignore because `--exclude=...` got tedious and there was ripgrep to answer my prayers.

Maintaining an alias would be more work than just `rg 'regex' .venv` (which is tab-completed after `.v`) the few times I'm looking for something in there. I like to keep my aliases clean and not have to use rg-all to turn off the setting I turned on. Like in your case, `alias rg='rg -u'`, now how do you turn it off?


> I tried a search to make grep ignore .gitignore because `--exclude=...` got tedious and there was ripgrep to answer my prayers.

To be clear, I was not suggesting an alias for grep, but for a hypothetical alternate ripgrep that searches everything by default but has a flag to skip ignored files. Something like

  alias rgi='rg --skip-ignored'
or whatever. Or if it came with a short flag that could work too, so you could use it without an alias easily.

> Like in your case, `alias rg='rg -u'`, now how do you turn it off?

You don't use the same name, you make a new alias. Like rgi or something. Bonus point is you find out immediately if it's missing.


I use very short aliases with fallbacks to standard tools if ripgrep/fd/bat/... isn't installed. For my use searching files in `.gitignore` is useless 9/10 times, why would I want that to be default?

> Or if it came with a short flag that could work too

It does, `-.` for hidden and `-u` for hidden + ignored.


> It does, `-.` for hidden and `-u` for hidden + ignored

I'm not sure you understood what I wrote? Those are opt-out. The entire discussion is about opt-in.


> Those are opt-out. The entire discussion is about opt-in.

Depends on your perspective, to me you have them flipped, and enabling them is "opt-in", i.e: "now I would like to see the hidden files please".

But I don't think I misunderstood you. You're telling me I should prefer hidden files to be the default, and I disagree and give my arguments. It's not more complicated than that.

To me rg only follows the same principle as the rest of my tools, fd requires `-H/--hidden`, ls `-a` or `-A` and so on. It is a big reason to why I prefer rg and fd over grep and find. Which brings us back to your first comment:

>> You started using it because it had that capability I imagine, not because it is the default.


`\rg foo` or `command rg foo`


I had that happen too recently… Basically rg x would show nothing but grep -r x showed the lines for any x. Tried multiple times with different x, then I kept using grep -r at that time. After a few days, I started using rg again and it worked fine but now I tend to use grep -r occasionally too to make sure.


Next time that happens try looking at the paths, adding a pair of -u, or running with --debug: by default rg will ignore files which are hidden (dotfiles) or excluded by ignore files (.gitignore, .ignore, …).

See https://github.com/BurntSushi/ripgrep/blob/master/GUIDE.md#a... for the details.


I use "grep" to search files (it should never skip any unless I tell it to do otherwise) and "git grep" to be a programmer searching a codebase (where it should only look at code files unless I tell it to do otherwise). Two different hats.

I wouldn't want to use tools that straddle the two, unless they had a nice clear way of picking one or the other. ripgrep does have "--no-ignore", though I would prefer -a / --all (one could make their own with alias rga='rg --no-ignore')


I had added a file to (I think) .git/info/exclude for .... reasons, which worked well until I couldn't find that file with rg. It's still my default grep though.


Maybe related to text encodings?

I think riggrep will not search UTF-16 files by default. I had some such issue once at least.


Could have been an incorrectly inferred encoding scheme?

I ran into that with pt, and it definitely made me think I was going mad[0]. I can't fully remember if rg suffered from the same issue or not.

[0] https://github.com/monochromegane/the_platinum_searcher/issu...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: