sharkdp / fd

A simple, fast and user-friendly alternative to 'find'
Apache License 2.0
34.32k stars 814 forks source link

[BUG] Too many levels of symbolic links (os error 62) #1363

Open anacrolix opened 1 year ago

anacrolix commented 1 year ago

Checks

Describe the bug you encountered:

/ % fd wireguard /opt/homebrew --show-errors -L [fd error]: /opt/homebrew/Library/Homebrew/vendor/gems/mechanize-2.9.1/mechanize-2.9.1: Too many levels of symbolic links (os error 62) [fd error]: /opt/homebrew/Library/Homebrew/vendor/gems/mechanize/mechanize-2.9.1: Too many levels of symbolic links (os error 62)

Describe what you expected to happen:

/ % find /opt/homebrew -name wireguard /opt/homebrew/etc/wireguard

What version of fd are you using?

fd 8.7.0

Which operating system / distribution are you on?

% uname -srm
Darwin 22.6.0 arm64
tavianator commented 1 year ago

What is the output of

/ % ls -l /opt/homebrew/Library/Homebrew/vendor/gems/mechanize-2.9.1/mechanize-2.9.1

? I suspect it really is a symbolic link loop.

anacrolix commented 1 year ago

You are quite right.

/opt/homebrew/Library/Homebrew/vendor/gems/mechanize % ls -l /opt/homebrew/Library/Homebrew/vendor/gems/mechanize-2.9.1/mechanize-2.9.1
lrwxr-xr-x@ 1 anacrolix  admin  16 22 May 14:40 /opt/homebrew/Library/Homebrew/vendor/gems/mechanize-2.9.1/mechanize-2.9.1@ -> mechanize-2.9.1/
/opt/homebrew/Library/Homebrew/vendor/gems/mechanize % cd mechanize-2.9.1
cd: too many levels of symbolic links: mechanize-2.9.1

I think this error is also recoverable: If we receive that error, drop following that symlink and just continue on to the next item. With this behaviour, --show-errors can retain its existing behaviour too: If enabled, the above error message can be displayed, otherwise it is not.

tavianator commented 1 year ago

Ohh I didn't notice the missing /opt/homebrew/etc/wireguard. I'm not sure that has to do with the loop error. Do any of these work?

/ % fd wireguard /opt/homebrew
/ % fd -L wireguard /opt/homebrew
/ % fd -u wireguard /opt/homebrew
anacrolix commented 1 year ago

@tavianator I thought you had found the issue with the symlink loop, but then I got this:

~ % fd wireguard /opt/homebrew
~ % fd -L wireguard /opt/homebrew
~ % fd -u wireguard /opt/homebrew
/opt/homebrew/opt/wireguard-tools
/opt/homebrew/opt/wireguard-go
/opt/homebrew/Cellar/wireguard-tools/
/opt/homebrew/Cellar/wireguard-tools/1.0.20210914_1/.brew/wireguard-tools.rb
/opt/homebrew/Cellar/wireguard-go/
/opt/homebrew/Cellar/wireguard-go/0.0.20230223/.brew/wireguard-go.rb
/opt/homebrew/Cellar/wireguard-go/0.0.20230223/bin/wireguard-go
/opt/homebrew/Cellar/zig/0.10.1/lib/zig/libc/include/any-linux-any/linux/wireguard.h
/opt/homebrew/Caskroom/android-ndk/25c/AndroidNDK9519653.app/Contents/NDK/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/linux/wireguard.h
/opt/homebrew/etc/wireguard/
/opt/homebrew/var/homebrew/linked/wireguard-tools
/opt/homebrew/var/homebrew/linked/wireguard-go
/opt/homebrew/bin/wireguard-go

I did not expect that with -u. So I ran

~ % fd ignore /opt/homebrew
/opt/homebrew/.dockerignore
/opt/homebrew/.gitignore

~ % fd wireguard /opt/homebrew --no-ignore
/opt/homebrew/opt/wireguard-go
/opt/homebrew/opt/wireguard-tools
/opt/homebrew/Cellar/wireguard-tools/
/opt/homebrew/Cellar/wireguard-go/
/opt/homebrew/Cellar/wireguard-go/0.0.20230223/bin/wireguard-go
/opt/homebrew/Cellar/zig/0.10.1/lib/zig/libc/include/any-linux-any/linux/wireguard.h
/opt/homebrew/Caskroom/android-ndk/25c/AndroidNDK9519653.app/Contents/NDK/toolchains/llvm/prebuilt/darwin-x86_64/sysroot/usr/include/linux/wireguard.h
/opt/homebrew/etc/wireguard/
/opt/homebrew/var/homebrew/linked/wireguard-go
/opt/homebrew/var/homebrew/linked/wireguard-tools
/opt/homebrew/bin/wireguard-go

I see the desired dir in the list /opt/homebrew/etc/wireguard/. What a ride. This seems like unintended behaviour here, clearly .gitignore in the homebrew dir is not intended to suppress searches in that directory.

tmccombs commented 1 year ago

That depends on the content of .gitignore

Mroczek1992 commented 1 year ago

8yzkfsoxput