Here's a guide for installing Ruby on Windows Subsystem for Linux (WSL) using rtx, a polyglot runtime manager:
-
Install RTX: First, install
rtx. You can do this by downloading the binary for Linux from the RTX releases page on GitHub. Choose the appropriate version for your system (e.g.,rtx-latest-linux-x64for 64-bit Linux).bashCopy code
curl -L https://github.com/jdx/rtx/releases/download/latest/rtx-latest-linux-x64 > ~/bin/rtx chmod +x ~/bin/rtx -
Add RTX to PATH: Make sure that
rtxis in your PATH. You can do this by adding the following line to your.bashrcor.zshrc:bashCopy code
export PATH="$HOME/bin:$PATH" -
Activate RTX: To initialize
rtxin your shell session, you need to add an activation command to your shell's configuration file. For Bash, add the following line to your.bashrc:bashCopy code
eval "$(~/bin/rtx activate bash)"For Zsh, add it to your
.zshrc. -
Install Ruby Using RTX: Now, you can use
rtxto install Ruby. Specify the version you want to install. For example, to install Ruby version 2.7.2:cssCopy code
rtx install ruby@2.7.2 -
Set Ruby Version: After installing, set the Ruby version for your project or globally. To set it for the current directory:
perlCopy code
rtx use ruby@2.7.2To set it globally (for all directories), use:
cssCopy code
rtx use --global ruby@2.7.2 -
Verify Installation: Finally, verify the installation by checking the Ruby version:
undefinedCopy code
ruby -v
This should install Ruby on your WSL environment using rtx. Remember to replace 2.7.2 with the version of Ruby you need.