install: fix error messages to align with GNU for cannot-stat and failed-to-remove.#9987
Open
sgmarz wants to merge 8 commits intouutils:mainfrom
Open
install: fix error messages to align with GNU for cannot-stat and failed-to-remove.#9987sgmarz wants to merge 8 commits intouutils:mainfrom
sgmarz wants to merge 8 commits intouutils:mainfrom
Conversation
Contributor
|
lot of jobs failing |
|
GNU testsuite comparison: |
|
GNU testsuite comparison: |
Contributor
|
please add tests to verify the errors & messages |
|
GNU testsuite comparison: |
Contributor
|
i think the rebase went wrong |
|
GNU testsuite comparison: |
…lity checks added and fixed.
…for failing to remove an existing file and one for trying to stat a file in /root.
…ms (e.g., (os error 13)) by using UIoError to print the error message.
9812121 to
acda29c
Compare
Collaborator
|
Fixed the rebase |
ChrisDryden
reviewed
Feb 14, 2026
| assert_eq!(0o40_200_u32, at.metadata(target_dir).permissions().mode()); | ||
| } | ||
|
|
||
| #[test] |
Collaborator
There was a problem hiding this comment.
The files that are being used to test do not exist on macos
ChrisDryden
reviewed
Feb 14, 2026
| // and it will give an incorrect error message. However, if we check to | ||
| // see if the file exists, and it can't even be checked, this means we | ||
| // don't have permission to access the file, so we should return an error. | ||
| if let Err(to_stat) = to.try_exists() { |
Collaborator
There was a problem hiding this comment.
Theres the pattern .map_err_contect that wraps these into errors in a simpler way thats used in the project that would make this much cleaner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #9934
This PR will update the failed-to-remove error message to better align with GNU coreutils. Furthermore, it adds "cannot stat" for when looking for a file to see if it exists fails. This can fail for myriad of reasons, including permission denied.
Test: original issue request
The original issue was due to the way Rust's standard library calculates
is_file. It only checks for regular files to be file, but on a UNIX configuration, the files could include block and character devices as well as a FIFO device. This patch now checks the metadata to check specifically for block, character, and FIFO devices on UNIX configurations. If the configuration is not UNIX, it reverts to the original behavior.Test: cannot stat due to permission error
The issue here was due to the way the
mainbranch doesremove_file. Since no checks are done before this function call, we get too granular of an error: was it due to not found or not? In this patch, there is an additional check using Rust's standardtry_exists. This will tell us if the actual calculation of a file existing failed.