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

[Bug Report] Error: No such file or directory (os error 2) because of "broken symbolic link" #124

Closed
c02y opened this issue May 11, 2022 · 3 comments · Fixed by #125
Closed
Labels
bug Something isn't working

Comments

@c02y
Copy link

c02y commented May 11, 2022

>> fd -HI -p 'gtk' '/home/user/' | wc -l
2976
>> dua a (fd -HI -p 'gtk' '/home/user/')
Error: No such file or directory (os error 2)

>> fd -HI -p 'desktop' '/home/user/' | wc -l
1437
>> dua a (fd -HI -p 'desktop' '/home/user/')
# works normally, thousands of lines below

>> fd -HI -p 'adwaita' '/' | wc -l
5900
>> dua (fd -HI -p 'adwaita' '/')
# works normally, thousands of lines below

This is not always happening as you can see, depending on the keywords I pass, so I analysed all the file types in the list and noticed some files are "broken symbolic link to..."

So

>> fd -HI -p 'gtk' '/home/user/' | wc -l
2976
>> dua a (fd -HI -p 'gtk' '/home/user/')
Error: No such file or directory (os error 2)

>> fd -HI -p  'gtk' '/home/user/' -X file | rg -v 'broken symbolic link' | awk '{sub(":", "", $1); print $1}' | wc -l
2966
>> dua (fd -HI -p  'gtk' '/home/user/' -X file | rg -v 'broken symbolic link' | awk '{sub(":", "", $1); print $1}')
# works normally, thousands of lines below

>> fd -HI -p  'gtk' '/home/user/' -X file | rg 'broken symbolic link' | awk '{sub(":", "", $1); print $1}'
/home/user/.local/share/Steam/steamapps/common/SteamLinuxRuntime_soldier/var/tmp-C73ZL1/usr/share/doc/gtk2-engines-pixbuf/AUTHORS
/home/user/.local/share/Steam/steamapps/common/SteamLinuxRuntime_soldier/var/tmp-C73ZL1/usr/share/doc/gtk2-engines-pixbuf/NEWS.gz
/home/user/.local/share/Steam/steamapps/common/SteamLinuxRuntime_soldier/var/tmp-C73ZL1/usr/share/doc/gtk2-engines-pixbuf/README.gz
/home/user/.local/share/Steam/steamapps/common/SteamLinuxRuntime_soldier/var/tmp-C73ZL1/usr/share/doc/gtk2-engines-pixbuf/changelog.gz
/home/user/.local/share/Steam/steamapps/common/SteamLinuxRuntime_soldier/var/tmp-C73ZL1/usr/share/doc/libgtk-3-0/NEWS.gz
/home/user/.local/share/Steam/steamapps/common/SteamLinuxRuntime_soldier/var/tmp-C73ZL1/usr/share/doc/libgtk-3-0/README
/home/user/.local/share/Steam/steamapps/common/SteamLinuxRuntime_soldier/var/tmp-C73ZL1/usr/share/doc/libgtk2.0-0/AUTHORS
/home/user/.local/share/Steam/steamapps/common/SteamLinuxRuntime_soldier/var/tmp-C73ZL1/usr/share/doc/libgtk2.0-0/NEWS.gz
/home/user/.local/share/Steam/steamapps/common/SteamLinuxRuntime_soldier/var/tmp-C73ZL1/usr/share/doc/libgtk2.0-0/README.gz
/home/user/.local/share/Steam/steamapps/common/SteamLinuxRuntime_soldier/var/tmp-C73ZL1/usr/share/doc/libgtk2.0-0/changelog.gz
>> fd -HI -p  'gtk2-engines-pixbuf/AUTHORS' '/home/user/' -X file | rg 'broken symbolic link' | awk '{sub(":", "", $1); print $1}'
/home/user/.local/share/Steam/steamapps/common/SteamLinuxRuntime_soldier/var/tmp-C73ZL1/usr/share/doc/gtk2-engines-pixbuf/AUTHORS
>> dua (fd -HI -p  'gtk2-engines-pixbuf/AUTHORS' '/home/user/' -X file | rg 'broken symbolic link' | awk '{sub(":", "", $1); print $1}')
Error: No such file or directory (os error 2)
@Byron Byron added the bug Something isn't working label May 11, 2022
@Byron
Copy link
Owner

Byron commented May 11, 2022

Thanks for a lot for letting me know.

The problem seems to be that it will completely fail if one root path on the command-line cannot be read. So dua a broken b will print nothing but a relatively undescriptive error message. Instead it should print at least the results for a, then <error> then the results for b.

dua i a broken b also doesn't come up even though I would expect it to showing at least a and b.

@c02y
Copy link
Author

c02y commented May 12, 2022

yeah, I have two solutions in mind:

  1. Ignore those files/dirs if they can not be read just like some read permission issue in files/dirs such as /proc
  2. simply do not read it and print the path (I'm not sure if this can be done easily)

Maybe provide a flag so dua ignores it or prints it.

Byron added a commit that referenced this issue May 12, 2022
Byron added a commit that referenced this issue May 12, 2022
…lts. (#124)

Previously it would fail completely without printing anything.
Byron added a commit that referenced this issue May 12, 2022
…ad. (#124)

Note that there can still be improvements in indicating which path
failed.
Also it will happily show an empty user interface in case all input
paths are not readable.
@Byron
Copy link
Owner

Byron commented May 12, 2022

Thanks for sharing! I think I have found a solution that works well with how these errors are usually handled.
You can take a look at the latest release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants