From c9320fddf1dcea68253df9caff6eb55a851a85bc Mon Sep 17 00:00:00 2001 From: Kyue <164024549+Gooh456@users.noreply.github.com> Date: Fri, 24 Jul 2026 14:15:01 +0100 Subject: [PATCH] install: don't reject existing non-regular targets as "invalid target" Signed-off-by: Kyue <164024549+Gooh456@users.noreply.github.com> --- src/uu/install/src/install.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/uu/install/src/install.rs b/src/uu/install/src/install.rs index 4c00a3e5703..84d920b6cd8 100644 --- a/src/uu/install/src/install.rs +++ b/src/uu/install/src/install.rs @@ -777,7 +777,12 @@ fn standard(mut paths: Vec, b: &Behavior) -> UResult<()> { return Err(InstallError::SameFile(source.clone(), target.clone()).into()); } - if target.is_file() || is_new_file_path(&target) { + // An existing target that isn't a directory (regular file, device + // node, FIFO, socket, ...) should still go through the normal + // copy/overwrite path so the real removal failure is reported, + // instead of falling through to InvalidTarget's hardcoded + // "No such file or directory" (issue #9934). + if target.is_file() || is_new_file_path(&target) || (target.exists() && !target.is_dir()) { #[cfg(unix)] if let (Some(ref parent_fd), Some(ref filename)) = (target_parent_fd, target_filename) { if b.compare && !need_copy(source, &target, b) {