mirror of
https://github.com/bootandy/dust.git
synced 2026-06-08 11:29:05 +03:00
[GH-ISSUE #90] Give a sensible error on nonexistent directories #35
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @ghost on GitHub (May 8, 2020).
Original GitHub issue: https://github.com/bootandy/dust/issues/90
This error message is wrong. I'd expect "no such file or directory" instead like ls.
@bootandy commented on GitHub (May 8, 2020):
Agreed, I'll look into this.
@agudeloromero commented on GitHub (Sep 7, 2023):
Hi there,
I am having the issue below and changing the permission didn't work.
Any advice?
Thanks in advance :)
@bootandy commented on GitHub (Sep 7, 2023):
can you run
dust --version.I can't replicate the above on my box.
@SteveLauC commented on GitHub (Dec 16, 2023):
Same here, tested with the latest commit
c8b61d2f46f5c1740bc93971deeb90c03b77cf68:@SteveLauC commented on GitHub (Dec 16, 2023):
Well, I checked out the source code, seems that PR #130 has been reverted? And the current behavior comes from the
walk()function:When
walk()ing a non-existing file,!dir.is_file()would be true, then theno_permissionsfield wil be set totrue, then we will get that errorDid not have permissions for all directories.@SteveLauC commented on GitHub (Dec 16, 2023):
Since dust uses rayon to iterate over the files under a directory, the current error-handling logic is probably hard to deal with such cases, what about we use a MPSC channel to connect the rayon threads and the main thread, when a rayon thread fails to do some I/O operation, it sends the error info to the main thread, then the main thread will stop the running threads and exit with the received error message
@bootandy commented on GitHub (Jan 4, 2024):
I think you are referring to something subtly different @SteveLauC - What you seem to be saying (correct me if I'm wrong) is that if the file doesn't exist it should print
No such file or directoryinstead ofDid not have permissions for all directories.The thinking behind this is to merge both similar errors:
No such file or directoryandcannot open directory 'foo': Permission deniedinto one error:Did not have permissions for all directories.The reason for the above decision is to minimize error output, early versions would print several rows like this:
cannot open directory 'tmp2': Permission denied,cannot open directory 'tmp3': Permission denied,cannot open directory 'tmp4': Permission deniedand your 'good' output was lost in a sea of permission errors.
I'm not entirely happy with the above decision, but it seemed like the best compromise - also that error message has confused other people. I will change the text to make it clearer. If you have any thoughts please comment.
This doesn't happen, the thread keeps running
@SteveLauC commented on GitHub (Jan 4, 2024):
Yes, I was talking about the error message, this is exactly what this issue wants:
I agree that the error handling here is kinda hard and it depends what you want
My last comment is indeed incorrect, we cannot stop a thread that is blocked/running, unless we abort the main thread, my last comment is more like that we
join()the rayon threads, and whenever any one of them gets an error, we just print the error message and exit. Though as I said,I am not sure if this model is what you want.
For error message propagation, I think it might be better to use
Box<dyn Error>orAnyhow::Errorsince there could be tons of error cases.@bootandy commented on GitHub (Jan 6, 2024):
I'm rethinking error messages in this branch: https://github.com/bootandy/dust/pull/360
this will bring back the 'no such file or directory' message
@bootandy commented on GitHub (Jan 7, 2024):
https://github.com/bootandy/dust/pull/361
version2 ^
@d-Rickyy-b commented on GitHub (Mar 30, 2024):
Since I might not be the only one, it might be helpful for others too. I got this error on every directory I tried, using the snap version of dust. When running as non-root, at least the home directory works, but no other dir. Using the binary from the github releases section works fine.
This is due to the way how snap handles applications and their permissions. This can be partly fixed by using the connect command.
Anyway, I found that using dust as a snap application is just not a smart idea.
@NBOOK commented on GitHub (Jul 12, 2025):
I think it would also be a good idea to return a sensible code when directories don't exist. I'll reuse the example above:
It seems that dust will return 0 regardless:
@bootandy commented on GitHub (Jul 29, 2025):
Hmmm, yes for that example I agree it should exit with a 1.
Question:
dust dir_exists dir_not_existsIf you run dust with 2 dirs ^ and 1 does not exist and 1 does. Is that still a 'success' ?
@bootandy commented on GitHub (Aug 1, 2025):
behavour changed in v1.2.3