Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some directories in .ignore aren't ignored #2836

Open
1 task done
jknoos opened this issue Jun 8, 2024 · 3 comments · May be fixed by #2933
Open
1 task done

Some directories in .ignore aren't ignored #2836

jknoos opened this issue Jun 8, 2024 · 3 comments · May be fixed by #2933
Labels
bug A bug. gitignore Bugs related to gitignore problems.

Comments

@jknoos
Copy link

jknoos commented Jun 8, 2024

Please tick this box to confirm you have reviewed the above.

  • I have a different issue.

What version of ripgrep are you using?

ripgrep 14.1.0

How did you install ripgrep?

pacman

What operating system are you using ripgrep on?

Arch Linux

Describe your bug.

Some directories in ~/.ignore aren't ignored correctly.

What are the steps to reproduce the behavior?

Run this script ~/test under ~/testdir:

#!/bin/bash

mkdir -p ~/testdir/sub/sub2
cd ~/testdir
chmod -r sub/sub2
echo 'sub/sub2' >> ~/.ignore
echo 'sub/sub2/' >> ~/.ignore
echo '/testdir/sub/sub2' >> ~/.ignore
echo '/testdir/sub/sub2/' >> ~/.ignore
rg --debug test

What is the actual behavior?

[~/testdir]$ ~/test
rg: DEBUG|rg::flags::parse|crates/core/flags/parse.rs:97: no extra arguments found from configuration file
rg: DEBUG|rg::flags::hiargs|crates/core/flags/hiargs.rs:1099: using heuristics to determine whether to read from stdin or search ./ (is_readable_stdin=false, stdin_consumed=false, mode=Search(Standard))
rg: DEBUG|rg::flags::hiargs|crates/core/flags/hiargs.rs:1109: heuristic chose to search ./
rg: DEBUG|rg::flags::hiargs|crates/core/flags/hiargs.rs:1260: found hostname for hyperlink configuration: t480s
rg: DEBUG|rg::flags::hiargs|crates/core/flags/hiargs.rs:1270: hyperlink format: ""
rg: DEBUG|rg::flags::hiargs|crates/core/flags/hiargs.rs:174: using 8 thread(s)
rg: DEBUG|grep_regex::config|crates/regex/src/config.rs:175: assembling HIR from 1 fixed string literals
rg: DEBUG|globset|crates/globset/src/lib.rs:453: built glob set; 0 literals, 0 basenames, 12 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
rg: DEBUG|globset|crates/globset/src/lib.rs:453: built glob set; 8 literals, 0 basenames, 0 extensions, 0 prefixes, 0 suffixes, 0 required extensions, 0 regexes
rg: ./sub/sub2: Permission denied (os error 13)
rg: No files were searched, which means ripgrep probably applied a filter you didn't expect.
Running with --debug will show why files are being skipped.
[~/testdir]$ 

What is the expected behavior?

~/testdir/sub/sub2 should be ignored, i.e. the rg: ./sub/sub2: Permission denied (os error 13) error is unexpected.

@BurntSushi
Copy link
Owner

Thanks for the bug report. I can reproduce this. Although here is something much simpler that doesn't rely on cluttering your $HOME directory:

$ mkdir -p /tmp/rg2836/testdir/sub/sub2
$ chmod -r /tmp/rg2836/testdir/sub/sub2
$ echo '/testdir/sub/sub2/' > /tmp/rg2836/.ignore

And then:

$ cd /tmp/rg2836
$ rg --files
create
$ cd testdir/
$ rg --files
rg: ./sub/sub2: Permission denied (os error 13)

Moving into the sub-directory should still result in the .ignore file being respected. But there's probably an issue dealing with stripping the right prefix of candidate paths with respect to the directory of the .ignore file.

This may also be related to #829 and #278, although not necessarily so.

@BurntSushi BurntSushi added bug A bug. gitignore Bugs related to gitignore problems. labels Jun 9, 2024
@tmccombs
Copy link
Contributor

tmccombs commented Aug 8, 2024

I think sharkdp/fd#1591 may be a case of this.

@gstokkink
Copy link

@BurntSushi #2770 might also be related

WalterScottYoung added a commit to WalterScottYoung/ripgrep that referenced this issue Nov 15, 2024
The previous code deleted too many parts of the path when constructing the absolute path, resulting in a shortened final path. This patch creates the correct absolute path by only removing the necessary parts.

Fixes BurntSushi#2836
WalterScottYoung added a commit to WalterScottYoung/ripgrep that referenced this issue Nov 15, 2024
The previous code deleted too many parts of the path when constructing the absolute path, resulting in a shortened final path. This patch creates the correct absolute path by only removing the necessary parts.

Fixes BurntSushi#2836
WalterScottYoung added a commit to WalterScottYoung/ripgrep that referenced this issue Nov 15, 2024
The previous code deleted too many parts of the path when constructing the absolute path, resulting in a shortened final path. This patch creates the correct absolute path by only removing the necessary parts.

Fixes BurntSushi#2836
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A bug. gitignore Bugs related to gitignore problems.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants