123456789_123456789_123456789_123456789_123456789_

The ridk tool

ridk is a helper tool to manage the runtime environment of RubyInstaller-2.4 and up. It can be used in cmd and powershell.

See ridk help for available sub-commands:

Usage:
    C:/Ruby24-x64/bin/ridk.cmd [option]

Option:
    install                   Install MSYS2 and MINGW dev tools
    exec <command>            Execute a command within MSYS2 context
    enable                    Set environment variables for MSYS2
    disable                   Unset environment variables for MSYS2
    version                   Print RubyInstaller and MSYS2 versions
    use                       Switch to a different ruby version
    help | --help | -? | /?   Display this help and exit

ridk install

See the following answer on Stackoverflow.

ridk enable / disable

This sets a bunch of environment variables required to execute MSYS2 commands. It makes sh, make, gcc, etc. available to the running console.

ridk enable allows to define the target environment to be enabled. This can be used to enable a cross build environment like ucrt64 on a mingw ruby like so

ridk enable ucrt64

ridk exec

Execute the given <command> with MSYS2 environment variables set properly.

  ridk exec pacman -Ss hello-world

Please note, that a maximum of 9 parameters is accepted only. That is due to restrictions of the cmd shell. For commands with more than 9 parameters use ridk enable and run the desired command without ridk exec prefix subsequently.

ridk version

This prints a series of ruby related version information to the console. Please use this output to submit issues.

ridk use

This sub-command can be used to switch the active ruby version within the running command shell. The interactive mode can be started on a console window with ridk use. By default it scans the Windows registry for RubyInstaller versions and let's you choose a version to change to. All RubyInstaller versions down to 1.8.7 are supported. ridk use always keeps itself in the PATH, so that it is possible to keep using it, even if the selected ruby version doesn't provide ridk use

There are some sub-commands as shown by ridk use help:

Usage:
    ridk use [<option>] [--default] [--system-default]

Option:
                  Start interactive version selection
    list          Search and list installed ruby versions
    update        Save or update the found ruby versions to rubies.yml
    <number>      Change the active ruby version by index
    /<regex>/     Change the active ruby version by regex
    help          Display this help and exit

    --default         Store the active ruby version in the user or
    --system-default  system environment variables permanently

ridk use update

Alternatively to scanning the registry a config file with ruby paths can be used. It can be created per ridk use update and is populated with all ruby versions that have been found in the registry. The config file is subsequently used and replaces the registry scan. If a new ruby version has been installed, the config file can be updated ridk use update, so that the new ruby becomes selectable.

ridk use /regex/

It is also possible to select per regular expression. With standard RubyInstaller paths this selects the x64 version ruby-2.5:

ridk use /25-/

while this selects the corresponding x86 version:

ridk use /25$/

The change of the ruby version is effective to the running shell only. To make the change permanent ridk use can be invoked with the options --default or --system-default. --default enables the selected ruby version in the user environment variables. --system-default enables the selected ruby version in the system environment variables, which requires admin permissions. Setting user environment variables might not get effective, since user PATH is added after system PATH, so that the per-user setting doesn't get effective, if the ruby version is already set system wide.