Skip to content

rm: misleading error message when removing file from unwritable directory #7307

@jfinkels

Description

@jfinkels

Environment: Ubuntu 24.04, uutils main branch (git commit 0eab0fa), GNU coreutils v9.4

Steps to reproduce:

mkdir -p a/b
touch a/b/file
chmod a-w a/b
rm -rf a

What happens now: uutils rm terminates with an error message about the top level directory:

rm: cannot remove 'a': Permission denied

What I expected to happen: GNU rm terminates with an error message about the innermost file:

rm: cannot remove 'a/b/file': Permission denied

Notes: this should cause a failure in GNU test file tests/rm/cycle.sh, but we are replacing the a/b/file in the expected error message with a

sed -i -e "s|rm: cannot remove 'a/b/file'|rm: cannot remove 'a'|g" tests/rm/cycle.sh
. I think cannot remove 'a' is misleading, and the original GNU error message seems to better match the conceptual model of how rm -r should work: it is a post-order tree traversal, and the leaf node cannot be removed because its parent directory does not allow writes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions