From de67d5453d61fdcf8d248d056934da323e8f32d8 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Wed, 12 Feb 2025 13:50:29 -0600 Subject: [PATCH] Check for executable permissions in `is_executable` (#11430) e.g., as in https://docs.rs/is_executable/latest/src/is_executable/lib.rs.html#44 --- crates/uv-fs/src/which.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/uv-fs/src/which.rs b/crates/uv-fs/src/which.rs index 26a68203d..d8342c313 100644 --- a/crates/uv-fs/src/which.rs +++ b/crates/uv-fs/src/which.rs @@ -27,9 +27,12 @@ pub fn is_executable(path: &Path) -> bool { } } - if cfg!(not(target_os = "windows")) { + #[cfg(not(target_os = "windows"))] + { + use std::os::unix::fs::PermissionsExt; + if !fs_err::metadata(path) - .map(|metadata| metadata.is_file()) + .map(|metadata| metadata.is_file() && metadata.permissions().mode() & 0o111 != 0) .unwrap_or(false) { return false;