Skip to content

Ignore: Panic occur when use walk with walkbuilder set both min_depth and max_path to some(1) and visit the system root_path #3286

@whihig

Description

@whihig

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

  • I have a different issue.

What version of ripgrep are you using?

ignore: 0.4.25
rust version: 1.94.0 (4a4ef493e 2026-03-02) (via rustc --version)

How did you install ripgrep?

cargo add ignore

What operating system are you using ripgrep on?

Windows11

Describe your bug.

I want to use the ignore crate to retrieve information about files in a specified directory while excluding the directory itself. To achieve this, I set both min_depth and max_depth to Some(1). However, a panic occurred when accessing the root directory.

What are the steps to reproduce the behavior?

On Windows11

mod test {
    use ignore::WalkBuilder;

    #[test]
    fn test_ignore_current_path() {
        let walk = WalkBuilder::new("C:\\").min_depth(Some(1)).max_depth(Some(1)).build();
        walk.into_iter().for_each(|entry| {
            println!("{:?}", entry);
        });
    }
}

On ArchLinux(WSL)

use ignore::WalkBuilder;
fn main() {
    let walk = WalkBuilder::new("/")
        .min_depth(Some(1))
        .max_depth(Some(1))
        .build();
    walk.into_iter().for_each(|entry| {
        println!("{:?}", entry);
    });
}

What is the actual behavior?

Here is the panic infomation when run on ArchLinux(WSL)

Image

What is the expected behavior?

I haven't looked at the specific usage of self.ig; maybe it needs to be changed to the type Option?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions