Hello,
The --ignore-file option doesn't work.
This bug report is not actionable. Please include a minimally reproducible example that demonstrates the problem you're experiencing. Please include all inputs, the expected output and the actual output. Please also include the version of ripgrep you're using and the OS you're running. Please make an effort to describe the problem in such a way that others can reproduce it exactly.
Next time you file a bug report (on any issue tracker for any project), please answer these questions up front instead of requiring other people to spend time asking for these things.
Sorry, here's a bit more info, I'm using macOS:
$ rg --version
ripgrep 0.6.0
-AVX -SIMD
I'm testing this on golang's standard library that contains _test.go files that I'd like to ignore
$ /usr/local/Cellar/go/1.7.1/libexec/src/crypto/tls/ rg --ignore-file tls_test.go panic
...
tls_test.go
...
I tried --ignore-file "tls_test.go" or --ignore-file "*_test.go" nothing works.
Switching to ag it works.
Please read the documentation of the flag you're using:
--ignore-file <FILE>...
Specify additional ignore files for filtering file paths. Ignore files should be in the
gitignore format and are matched relative to the current working directory. These ignore
files have lower precedence than all other ignore files. When specifying multiple ignore
files, earlier files have lower precedence than later files.
If you want to ignore a specific file or files that end in a certain suffix, then use rg -g '!*_test.go' panic. There are more examples in the README.
I read the documentation. What is wrong with the way I use --ignore-file? I'm not sure I understand your answer. I've looked for information elsewhere here but I can't find any.
The --ignore-file flag, as documented, specifies a path to a file that specifies a list of ignore rules, which is of the same format as .ignore and .gitignore. In the command you've provided, you're telling ripgrep to read ignore rules from tls_test.go, which is a Go source file, and not a file containing ignore rules.
If I run the command you provided, ripgrep is telling you that the given ignore file is invalid by spewing a bunch of errors.
Oh ok I see! I guess I did not understand the phrasing like this.
Just spent about 30 minutes trying to figure the same thing out. The documentation may be accurate, but still not making it easy to understand it and very easy to confuse.
This:
specifies a path to a file that specifies a list of ignore rules, which is of the same format as .ignore and .gitignore
should be in the documentation instead.
@clehene Could you say what is confusing about the current docs specifically? As far as I can tell, they basically say the same thing as your revision. They even include a tip to use -g if you want to include/exclude files directly on the command line.
@BurntSushi not sure if this is better https://github.com/BurntSushi/ripgrep/pull/817 but the goal is to make the intention clear immediately.
I did rg --help then searched for ignore, got to ignore-file and understood it takes ignore patterns. Tried, failed read a few more times. Tried with gitignore patterns, failed and after a few googles got to this issue :). I think it's the fact that I was sure this is the right flag that made me overlook the rest. Perhaps the flag name is too easy to confuse..
@clehene Interesting! I definitely agree that the flag name is not ideal. You are not the only person I've seen get hung up on this. Let's iterate on the exact re-wording in your PR. :)
Most helpful comment
Please read the documentation of the flag you're using:
If you want to ignore a specific file or files that end in a certain suffix, then use
rg -g '!*_test.go' panic. There are more examples in the README.