-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Windows] Command:spawn() only searches for .exe
files
#37380
Comments
Windows relies on path extensions to resolve commands, extensions are found in the `PATHEXT` environment variable. We are adding a new function called `Command:find_program()` that will return the `Path` of the program found using the above env variable. Closes rust-lang#37380 Signed-off-by: Salim Afiune <afiune@chef.io>
Since only `git.bat` is found in the `PATH` on Windows ChefDK installs: https://github.com/chef/omnibus-software/blob/master/config/software/git-windows.rb#L50-L52 `delivery-cli` commands that shell out to `git` fail because Git can not be found when Rust tries to find the executable to be spawned. This is because Rust's Windows spawn command, when provided with a file path without an extension, will only search for `.exe` files when searching the path: rust-lang/rust#37380 https://github.com/rust-lang/rust/blob/master/src/libstd/sys/windows/process.rs#L141 https://github.com/rust-lang/rust/blob/master/src/libstd/sys/windows/env.rs#L18 This change adds a `find_command` that uses the `PATHEXE` env variable on Windows to also search for other valid Git executables in addition to `.exe`. http://environmentvariables.org/PathExt This is the same approach Habitat took when they ran into this issue: https://github.com/habitat-sh/habitat/pull/1290/files#diff-5fb0c7b1056276e7845dbf93cb430542R258
From the pull request: "It sounds like this behavior is specific to cmd.exe not CreateProcess. We're emulating the latter, so it sounds like we may not wish to merge this." As such, I'm going to close. |
Hello @Mark-Simulacrum Sorry for bumping this, I've a problem with |
Let's open a new issue, and please link here and to the PR. Are |
Problem Description
In the Windows world you have
.exe
files but you can also have.bat
files that can be executables in yourPATH
. The problem is that the implementation of theCommand:spawn()
in windows only checks for EXE (https://github.com/rust-lang/rust/blob/master/src/libstd/sys/windows/process.rs#L141) that means that if we have some BAT files that we would like to execute we currently can't.Proposal Solution
Instead of checking just for EXE files we should check the
PATHEXT
Environment Variable to detect what available extensions we search for.The text was updated successfully, but these errors were encountered: