Skip to content

mv: raw ENOTDIR instead of translated error under WASI #15358

Closed

Description

@eduardomourar

mv -T replacing a symlink-to-a-file with a directory should fail with the translated "cannot overwrite non-directory ... with directory ..." message, matching native behavior. Under the WASI sandbox, a raw ENOTDIR ("Not a directory") surfaces instead.

Found while enabling WASI integration tests for mv in #15320; the affected test (test_mv_replace_symlink_with_directory in tests/by-util/test_mv.rs) is currently skipped under wasi_runner with this note.

Likely cause: handle_two_paths in src/uu/mv/src/mv.rs decides whether to emit the translated message by checking target.exists() after resolving the symlink. On native targets this is true (the symlink's file target exists) and the code takes the source_is_dir && target.exists() branch, producing MvError::NonDirectoryToDirectory. Under wasmtime, exists() on that same symlink-to-file appears to return false, so the code falls through to the plain rename() path instead, where the raw ENOTDIR from the underlying rename(2) call is returned unwrapped.

To reproduce under wasmtime:

touch a
mkdir b
touch b/empty_file_b
ln -s a symlink
mv -T b symlink

Expected: mv: cannot overwrite non-directory 'symlink' with directory 'b'
Actual (WASI): mv: Not a directory (os error 54)

Activity

  1. added a commit that references this issue on Oct 15, 2026
    2fb77e8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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