Search cygpath.exe from Git's install path
I was trying the Shebang Recipes function and got this error:
C:\Users\hyrious\Desktop\Sakuna>just ruby
error: Could not find `cygpath` executable to translate recipe `ruby` shebang interpreter path:
program not found
This was because I do not have cygpath in my PATH. I do have cygpath.exe in the installation directory of Git and MSYS2, but they are not added to PATH for not polluting my normal shell. For example, PowerShell would prefer echo.exe (from bash) over the echo command, they behave differently obviously.
While the most complete solution may be quite complex regarding to #1549 and #2599. I have a more trivial feature request that, just can search for cygpath.exe from common paths like a relative path to Git:
C:\Users\hyrious\Desktop\Sakuna>C:\progra~1\Git\usr\bin\cygpath --version
cygpath (cygwin) 3.4.10
Path Conversion Utility
Copyright (C) 1998 - 2024 Cygwin Authors
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
C:\Users\hyrious\Desktop\Sakuna>C:\progra~1\Git\usr\bin\cygpath ruby
ruby
The basic logic is as follows:
-
See if
C:\progra~1\Git\usr\bin\cygpath.exeexists. This is the default location that Git for Windows will be installed at. It is highly possible that there's acygpath.exe. -
If not, search for
git.exebywhere gitor simply iterating over the PATH environment. -
If
gitexists, resolve thecygpathbyjoin(git_path, '../../usr/bin/cygpath.exe').> fs.existsSync(path.join(String.raw`C:\Progra~1\Git\cmd\git.exe`, '../../usr/bin/cygpath.exe')) true
You're free to choose not to implement that.
I think I probably wouldn't want to try to guess where cygpath.exe is. However, we could add a command line flag --cygpath which takes the path to the cygpath.exe executable. This would be kind of annoying, since you would have to do just --cygpath FOO every time you invoked just, except all command line flags are configureable with environment variables, so you could set JUST_CYGPATH=FOO in your environment and you wouldn't have to add the flag.
I think this would be pretty straightforward, so adding the "good first issue" tag in case anyone wants to take a crack at it.