From 765b14f46edb295d803ef77d7a64865ca633e97a Mon Sep 17 00:00:00 2001 From: l0ng-ai <24760907+l0ng-ai@users.noreply.github.com> Date: Mon, 2 Nov 2026 12:04:38 +0800 Subject: [PATCH] fix(run): take extensionless names from the run directory only through PATHEXT --- crates/ide-run/src/process.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/crates/ide-run/src/process.rs b/crates/ide-run/src/process.rs index 4e1bf5c47..0590c8296 100644 --- a/crates/ide-run/src/process.rs +++ b/crates/ide-run/src/process.rs @@ -252,8 +252,10 @@ fn resolve_program(command: &str, cwd: &Path, config: &RunConfig, windows: bool) let search = crate::wrap::search_path(config); let pathext = std::env::var("PATHEXT").ok(); if windows { + // As cmd.exe does: the run directory first, a name with an extension as is, + // an extensionless one only through PATHEXT (a POSIX `gradlew` script is not runnable). let local = cwd.join(path); - if local.is_file() { + if path.extension().is_some() && local.is_file() { return local; } if path.extension().is_none() @@ -1178,10 +1180,11 @@ mod tests { assert_eq!(resolve_program(name, cwd, &config, true), bin.join(name)); assert_eq!(resolve_program(bare, cwd, &config, true), bin.join(name)); } - // Exact files are checked before PATHEXT candidates, and directories are ignored. + // An extensionless file is not runnable on Windows: only PATHEXT candidates count, + // and directories are ignored. std::fs::write(cwd.join("local-tool"), "tool").unwrap(); std::fs::write(cwd.join("local-tool.exe"), "tool").unwrap(); - assert_eq!(resolve_program("local-tool", cwd, &config, true), cwd.join("local-tool")); + assert_eq!(resolve_program("local-tool", cwd, &config, true), cwd.join("local-tool.exe")); assert_eq!(resolve_program("local-tool", cwd, &config, false), PathBuf::from("local-tool")); std::fs::remove_file(cwd.join("local-tool")).unwrap(); assert_eq!(resolve_program("local-tool", cwd, &config, true), cwd.join("local-tool.exe"));