install: fix error messages to align with GNU for cannot-stat and failed-to-remove. #9987
+35
−7
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.