-
Notifications
You must be signed in to change notification settings - Fork 256
For gem developers
Dependent DLLs can be loaded by using the function RubyInstaller::Runtime.add_dll_directory
, like in the pg gem .
It is not sufficient to add the DLL directory to the PATH
environment variable.
RubyInstaller2 ignores the PATH
variable for all DLL searches.
It is possible to specify dependencies to MSYS2-packages or MSYS2-MINGW packages in the gemspec of a gem to be installed.
Set gemspec.metadata['msys2_dependencies']
or gemspec.metadata['msys2_mingw_dependencies']
to a space separated list of pacman packages.
Optionally the name can be followed by a version restriction.
However keep in mind that MSYS2 usually provides only one version at the same time for each package.
Examples:
gemspec.metadata['msys2_mingw_dependencies'] = 'libusb sqlite'
or
gemspec.metadata['msys2_mingw_dependencies'] = 'libusb>=1.0.21'
MSYS2 package dependencies are installed per pacman
command, when a gem is about to be installed. The extconf.rb
within a gem can access the newly installed MSYS2-MINGW libraries.
If the package installation fails, the output of pacman
is printed to the console, but the gem installation continues nevertheless.
Insofar setting a MSYS2 dependency can make the installation easier, but will not brake the gem installation in case of changed MSYS2 packages.
Installation of MSYS2(-MINGW) packages can be disabled per gem install gemname.gem --ignore-dependencies
.
Simple rule: Use backslashs for escaping and forward slashs as filesystem path separator.
Although the "official" path separator on Windows is the backslash, almost all Windows APIs calls accept forward slashs as well, regardless of the Windows version.
Since Ruby on Windows returns forward slashs for Dir.glob
and others, it is best to completely avoid backslashs in paths written in ruby code.
This makes the code portable and more readable.
Note: Registry access (per stdlib win32/registry
) requires the use of backslashs.
Shell escaping is a very difficult thing on Windows, since there are so many different shells (cmd, powershell, bash, msvcrt) with very different and partly obscure escaping rules.
The Ruby stdlib shellwords
supports bash escaping only (although there is an implementation on github for Windows shells).
So using shellwords often makes things even worse.
It is therefore best to avoid shell escaping at all by using Array argument methods where possible:
system('program', 'with arguments') # instead of system("program 'with arguments'")
out = IO.popen('program', 'with arguments', &:read) # instead of out = `program 'with arguments'`