-
Notifications
You must be signed in to change notification settings - Fork 691
Description
I created gnu-tk tool that provides seamless access to GNU toolkits on non-GNU operating systems. I provided more details about it in this discussion.
When verifying gnu-tk with just, I found a bug in just that occurs when it searches for executable files using PATH environment variable.
Consider justfile with a custom shebang line:
run:
#!gnu-tk -l bash
echo Hello from cross-platform GNU scripting
If gnu-tk is installed as NuGet package (dotnet tool install -g Gapotchenko.GnuTK), everything works as expected when just run command is issued:
Hello from cross-platform GNU scripting
But if gnu-tk is installed as NPM package (npm install -g @gapotchenko/gnu-tk), just run results in the following error:
error: Recipe `run` with shebang `#!gnu-tk -l bash` execution error: program not found
Both NuGet and NPM package managers install gnu-tk tool and it is available in the command shell of the system:
> gnu-tk --version
GNU-TK 2025.2.5
but they do it differently.
NuGet installs gnu-tk.exe file at C:\Users\Tester\.dotnet\tools directory which is a part of PATH environment variable. just finds it there and everything works.
NPM installs gnu-tk.cmd file at C:\Users\Tester\AppData\Roaming\npm directory which is also enlisted in PATH environment variable. But the file created by NPM has .cmd extension as opposed to .exe, and this time just cannot find gnu-tk program. This leads to the program not found error.
This is a common issue that arises when developers attempt to replicate the semantics of which/where utility in their code. The right way to do it on Windows is to use PATHEXT environment variable that enumerates file extensions that should be treated as launchable programs. Here is an example implementation of an executable file lookup in Windows.
Environment
Version: just 1.42.1
OS: Windows 11 x64