Please tick this box to confirm you have reviewed the above.
What version of ripgrep are you using?
ripgrep 15.1.0
features:+pcre2
simd(compile):+NEON
simd(runtime):+NEON
PCRE2 10.45 is available (JIT is available)
How did you install ripgrep?
Homebrew
What operating system are you using ripgrep on?
macOS 15.7.4
Describe your bug.
rg appears to handle .rgignore inconsistently when multiple explicit search roots are provided.
In a minimal repro with:
.rgignore containing beta/**/*.svg
alpha/a.txt containing AWS
beta/x.svg containing AWS
the command:
rg --files-with-matches -n 'AWS' alpha beta
incorrectly returns beta/x.svg, even though it matches the ignore rule.
If I run the same search with the roots reversed:
rg --files-with-matches -n 'AWS' beta alpha
then beta/x.svg is correctly ignored.
So the bug seems to be that .rgignore handling is order-dependent when multiple explicit search roots are passed to ripgrep.
What are the steps to reproduce the behavior?
Create this minimal repro directory:
.
├── .rgignore
├── alpha/
│ └── a.txt
└── beta/
└── x.svg
With these contents:
.rgignore
alpha/a.txt
beta/x.svg
Then run these commands from that directory:
rg --files-with-matches -n 'AWS' beta
rg --files-with-matches -n 'AWS' alpha beta
rg --files-with-matches -n 'AWS' beta alpha
You can also reproduce it with this shell script:
mkdir repro && cd repro
mkdir -p alpha beta
printf 'beta/**/*.svg\n' > .rgignore
printf 'AWS\n' > alpha/a.txt
printf 'AWS\n' > beta/x.svg
rg --files-with-matches -n 'AWS' beta
rg --files-with-matches -n 'AWS' alpha beta
rg --files-with-matches -n 'AWS' beta alpha
What is the actual behavior?
The result depends on the order of the explicit search roots.
Command:
rg --files-with-matches -n 'AWS' alpha beta
Actual output:
But beta/x.svg should be ignored by .rgignore because it matches:
If I swap the root order:
rg --files-with-matches -n 'AWS' beta alpha
the output changes to:
which is what I expect.
--debug for the working order shows that ripgrep does recognize the ignore rule and ignores beta/x.svg:
rg --debug --files-with-matches -n 'AWS' beta alpha
Relevant debug output:
rg: DEBUG|ignore::walk|crates/ignore/src/walk.rs:1942: ignoring beta/x.svg: Ignore(IgnoreMatch(Gitignore(Glob { from: Some("/path/to/repro/.rgignore"), original: "beta/**/*.svg", actual: "beta/**/*.svg", is_whitelist: false, is_only_dir: false })))
So the bug appears to be that ignore handling is order-dependent when multiple explicit search roots are provided.
What is the expected behavior?
Both commands should produce the same result regardless of the order of the explicit search roots, and both should respect .rgignore.
Given this ignore rule:
beta/x.svg should never be searched.
So both of these commands:
rg --files-with-matches -n 'AWS' alpha beta
rg --files-with-matches -n 'AWS' beta alpha
should return:
and should not report beta/x.svg.
Please tick this box to confirm you have reviewed the above.
What version of ripgrep are you using?
ripgrep 15.1.0
features:+pcre2
simd(compile):+NEON
simd(runtime):+NEON
PCRE2 10.45 is available (JIT is available)
How did you install ripgrep?
Homebrew
What operating system are you using ripgrep on?
macOS 15.7.4
Describe your bug.
rgappears to handle.rgignoreinconsistently when multiple explicit search roots are provided.In a minimal repro with:
.rgignorecontainingbeta/**/*.svgalpha/a.txtcontainingAWSbeta/x.svgcontainingAWSthe command:
rg --files-with-matches -n 'AWS' alpha betaincorrectly returns
beta/x.svg, even though it matches the ignore rule.If I run the same search with the roots reversed:
rg --files-with-matches -n 'AWS' beta alphathen
beta/x.svgis correctly ignored.So the bug seems to be that
.rgignorehandling is order-dependent when multiple explicit search roots are passed to ripgrep.What are the steps to reproduce the behavior?
Create this minimal repro directory:
. ├── .rgignore ├── alpha/ │ └── a.txt └── beta/ └── x.svgWith these contents:
.rgignorealpha/a.txtbeta/x.svgThen run these commands from that directory:
You can also reproduce it with this shell script:
What is the actual behavior?
The result depends on the order of the explicit search roots.
Command:
rg --files-with-matches -n 'AWS' alpha betaActual output:
But
beta/x.svgshould be ignored by.rgignorebecause it matches:If I swap the root order:
rg --files-with-matches -n 'AWS' beta alphathe output changes to:
which is what I expect.
--debugfor the working order shows that ripgrep does recognize the ignore rule and ignoresbeta/x.svg:rg --debug --files-with-matches -n 'AWS' beta alphaRelevant debug output:
rg: DEBUG|ignore::walk|crates/ignore/src/walk.rs:1942: ignoring beta/x.svg: Ignore(IgnoreMatch(Gitignore(Glob { from: Some("/path/to/repro/.rgignore"), original: "beta/**/*.svg", actual: "beta/**/*.svg", is_whitelist: false, is_only_dir: false })))So the bug appears to be that ignore handling is order-dependent when multiple explicit search roots are provided.
What is the expected behavior?
Both commands should produce the same result regardless of the order of the explicit search roots, and both should respect
.rgignore.Given this ignore rule:
beta/x.svgshould never be searched.So both of these commands:
should return:
and should not report
beta/x.svg.