I want to have a certain executable available in my %PATH% under Windows. The catch here is that the tool is in a directory where there are a lot of other executables which I don't want to have in my PATH, so I can't just add the whole directory.
In my Linux systems, I would just symlink the executable into $HOME/bin
, which is in $PATH, and it would get picked up from there. But on Windows, creating symbolic links is restricted to admin users and Microsoft warns about some vague security concerns, so I'm reluctant to play around with that.
What is the Windows equivalent to ln -s $SOME_EXECUTABLE_FILE $HOME/bin/
?
I saw the Chocolatey solves that problem by generating shim executables, but their shimgen tool is proprietary and only licensed for use as part of their package manager.
Edit: Simply symlinking the executable like I would on a Linux system appears to break DLL loading. Here's what happens when I try symlinking an executable to a different folder on Windows:
C:\tmp>mklink ruby.exe C:\tools\msys64\mingw64\bin\ruby.exe
symbolic link created for ruby.exe <<===>> C:\tools\msys64\mingw64\bin\ruby.exe
C:\tmp>.\ruby.exe
### error dialog about not finding libgmp-10.dll and libssp-0.dll
The missing DLL files are in the bin
directory. Apparently, Windows does not look in the "real" directory of an executable if the executable is invoked via a symlink.
It works in the same CMD session when I invoke it via its full path:
C:\tmp>C:\tools\msys64\mingw64\bin\ruby.exe
puts 'Hello world'
^D
Hello world