Skip to content

[BUG] --exclude quirk, only seems to affect first --search-path in some cases (without glob) #1919

@luckman212

Description

@luckman212

Checks

  • I have read the troubleshooting section and still think this is a bug.

Bug

I believe this is a bug. It's probably at least tangentially related to #851, #374, and #1577.

When multiple --search-path arguments are supplied, fd appears to ignore (not respect) the --exclude directive when processing dirs after the first search path.

Repro

I wrote a very simple bash script to repro this:

#!/usr/bin/env bash

fd --version

echo "only 'myfile1.txt' should be found"
echo

# dir1
mkdir -p ~/test/abc/def
mkdir -p ~/test/ghi/def
touch ~/test/abc/def/myfile1.txt
touch ~/test/ghi/def/myfile2.txt

# dir2
mkdir -p ~/test2/abc/def
mkdir -p ~/test2/ghi/def
touch ~/test2/abc/def/myfile1.txt
touch ~/test2/ghi/def/myfile2.txt

echo "this works: --exclude 'ghi'"
fd --type file --search-path ~/test --search-path ~/test2 --exclude 'ghi'
echo

echo "this also works: --exclude '**/ghi/def'"
fd --type file --search-path ~/test --search-path ~/test2 --exclude '**/ghi/def'
echo

echo "this seems to NOT work as expected: --exclude 'ghi/def'"
echo "(~/test2/ghi/def/myfile2.txt will be shown)"
fd --type file --search-path ~/test --search-path ~/test2 --exclude 'ghi/def'

Output

$ ./fd_repro.sh
fd 10.4.2
only 'myfile1.txt' should be found

this works: --exclude 'ghi'
/Users/luke/test/abc/def/myfile1.txt
/Users/luke/test2/abc/def/myfile1.txt

this also works: --exclude '**/ghi/def'
/Users/luke/test/abc/def/myfile1.txt
/Users/luke/test2/abc/def/myfile1.txt

this seems to NOT work as expected: --exclude 'ghi/def'
(~/test2/ghi/def/myfile2.txt will be shown)
/Users/luke/test/abc/def/myfile1.txt
/Users/luke/test2/abc/def/myfile1.txt
/Users/luke/test2/ghi/def/myfile2.txt

Describe what you expected to happen:

Did not expect any of the commands to surface /Users/luke/test2/ghi/def/myfile2.txt

What version of fd are you using?

fd 10.4.2

Which operating system / distribution are you on?

macOS 26.3.2 (25D2140)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugignore-forkThis would benefit from using a custom fork of the ignore crate.upstream-feature

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions