see all versions of ruby download How to Manage Multiple Versions of Ruby on Windows. I had recently started work on a Rails project and was setting up my local dev environment which I wanted to make it as similar as possible to the environment on the server I will deploy to. The remote server currently runs Ruby 1.9.2 and Rails 3.x, so this is what I installed on my local machine. Whilst ensuring that everything worked as expected, I noticed was that WEBrick was very slow to boot. However, as this only needs to be done once (or occasionally twice) per session, I didn’t think much more of it. I then started coding, wrote some simple tests then ran rake test from the console. And waited, and waited, and waited… My minimal set of tests took over one and a half minutes to run. WTF. This was something that would seriously slow me down. I did some Googling and found out that I wasn’t the only one who was having issues with Rails 3 and Ruby 1.9.2. I read through a couple of questions on StackOverflow and found that one proposed solution was to upgrade to 1.9.3. Hmmm… I wanted to keep Ruby 1.9.2 installed, but needed a way to speed things up, so I started looking for ways to manage multiple Ruby versions on Windows (yes, I know, Windoof, but just remember that you cannot play Skyrim on Linux without performing a backwards somersault through your own sphincter). That’s when I discovered pik. Installing pik. pik bills itself as a tool to manage multiple versions of Ruby on Windows which can be used from the Windows command line (cmd.exe), Windows PowerShell, or Git Bash. It sounded ideal for the job. In order to install pik you need a working version of Ruby. No problemo, I had already installed 1.9.2 using the mighty RubyInstaller. After that, as you can install pik via rubygems, it’s a matter of opening a command prompt and typing: If the gem installs successfully, you’ll see a message telling you to use the pik_install script to install the pik executable. You need to install it somewhere that’s located in your PATH , but not your ruby/bin directory. I did this (taking care with the backslash): As C:/pik isn’t in my PATH , I had to add it manually and restart the PC. Here’s a brief tutorial on how to do that (alter your PATH variable, not restart the PC). So following the reboot, it was time to install Ruby 1.9.3. I opened a command prompt and typed: Download Ruby. Here you can get the latest Ruby distributions in your favorite flavor. The current stable version is 3.0.2. Please be sure to read Ruby’s License. Ways of Installing Ruby. We have several tools on each major platform to install Ruby: On Linux/UNIX, you can use the package management system of your distribution or third-party tools (rbenv and RVM). On macOS machines, you can use third-party tools (rbenv and RVM). On Windows machines, you can use RubyInstaller. See the Installation page for details on using package management systems or third-party tools. Of course, you can also install Ruby from source on all major platforms. Compiling Ruby — Source Code. Installing from the source code is a great solution for when you are comfortable enough with your platform and perhaps need specific settings for your environment. It’s also a good solution in the event that there are no other premade packages for your platform. See the Installation page for details on building Ruby from source. If you have an issue compiling Ruby, consider using one of the third party tools mentioned above. They may help you. Stable releases: sha256: 5085dee0ad9f06996a8acec7ebea4a8735e6fac22f22e2d98c3f2bc3bef7e6f1 sha256: 3043099089608859fc8cce7f9fdccaa1f53a462457e3838ec3b25a7d609fbc5b sha256: 1807b78577bc08596a390e8a41aede37b8512190e05c133b17d0501791a8ca6d sha256: f5894e05f532b748c3347894a5efa42066fd11cc8d261d4d9788ff71da00be68 : This is a tarball of the latest snapshot of the current ruby_3_0 branch. : This is a tarball of the latest snapshot of the current ruby_2_7 branch. : This is a tarball of the latest snapshot of the current ruby_2_6 branch. : This is a tarball of whatever is in Git, made nightly. This may contain bugs or other issues, use at your own risk! For more information about specific releases, particularly older releases or previews, see the Releases page. Information about the current maintenance status of the various Ruby branches can be found on the Branches page. For information about the Ruby Subversion and Git repositories, see our Ruby Core page. The Ruby source is available from a worldwide set of Mirror Sites. Please try to use a mirror that is near you. Ruby on Windows Guides. Up to now we were managing multiple versions of Ruby through ConEmu tasks. Even though we can use different Ruby versions this way, such approach has few drawbacks. Testing scripts or running existing applications that relly on specific Ruby version require opening new or changing to tab that already has target Ruby activated. Adding new Ruby version is somewhat complex and soon we might finish with too many different tabs in ConEmu so it would be hard to remember which tab corresponds to particular Ruby version. Especially if we decide to install other Rubies besides MRI, like JRuby or IronRuby. At the moment we have two versions of Ruby on our system. The first one is official 2.2.1-p85 and the second one is the latest development version. Since we have used installer for the 2.2.1 and have chosen to add it to the path, in each Command Prompt we open it will be the only one available unless we add the path to the development version to the system path. So we have to choose either to use Ruby in ConEmu's tabs or to constantly alter system path in order to change Ruby version we work with. This certainly is not the most comfortable way and, fortunately, there is a much better solution. Uru is new, lightweight, portable Ruby version manager which can be used to easily switch Ruby versions in the current Command Prompt. In order to install it you have to download archive with latest version from Bitbucket and unpack it in some folder that is in the PATH. In order to keep things isolated let's create new directory C:\tools and add it to the path as is explained in the first chapter - Windows Command Line. Open command prompt, go to target directory and execute following command: This will "install" Uru by creating two scipts in the same folder: uru.bat and uru.ps1 . Starting Uru without any option will display help screen with all available commands: If you now check which Ruby versions are registered with Uru you will see that it still doesn't know anything about existing Rubies on our system. As you can see from the help screen Uru has admin command which is used to administer installation. Executing following command will display information about available admin subcommands. So in order to register Ruby version with Uru we have to execute uru admin add with a directory of Ruby's bin folder as an argument. Let's register our first Ruby with Uru: By executing same command but this time with directory where our current development Ruby version is we will register second Ruby version. Listing Rubies known to Uru will now show both our versions. Now we can easily switch currently used Ruby version. Just to be sure check which Ruby is active now. Similarly we can switch Ruby to latest development version: But how we will switch Ruby version if we have multiple patchlevels of same version installed (same build numbers i.e 2.2.1 with different number after 'p', i.e. p85)? If we invoke Uru with only base version info and we have multiple patchlevels installed we will get following output: You can see that Uru is smart enough to display all versions that match version information given in the switch command. Now you can easily choose version or quit by entering 0. If you want to avoid this additional step you can use version tag which Uru displays after installing new version, in output of uru ls command or in the menu that appears if conflicting versions are found when version switch command is executed. In the above example these tags are 221p85 and 221p95. So executing: will immediately change active Ruby version. There's much more you can do with Uru. Define gemsets on project level, change Ruby tag value, etc. but that's beyond the scope of this book. Another Ruby version manager available on Windows is Pik. Pik is quite old and not maintained any more but still can be used for managing installed Rubies. Since Pik is quite old and all samples are written for old Rubies and are not updated for newest versions. Pik is implemented as Ruby gem so it is installed as any other Ruby gem. Open new Command Prompt window (not ConEmu) and execute following command: Command is executed in the new Command Prompt where the only Ruby available, at the moment, is 2.2.1, therefore gem will be installed in it. Let's check that: As you can see Pik is available in the list of gems currently available to the default Ruby. If you wonder where other gems come from when we didn't install them they are bundled with Ruby and are available with Ruby installation. It is time to finalize Pik installation. Comments displayed after gem is installed are self-explanatory but let's analyze them. We are not upgrading Pik so we can skip the first one. The second one states that we must use pik_install command in order to install Pik, and we should pass it, as argument, some directory that is in the path. It is recommended to avoid our ruby\bin directory. Currently our path contains directories added during Windows installation, directory where Git is installed and, finally, bin directory of our Ruby 2.2.1 version. Since I like to keep things clear we will create new directory which we will use when we launch pik_install command. We'll follow Pik's suggestion and install it in previously created C:\tools directory. As a good behaved tool, Pik displayed everything it did during installation. First it created directory where it installed it's files, C:\tools in our case. If directory already exists Pik will do nothing. Next, it creates .pik directory in C:\Users\bosko . But why does Pik chose this directory? On the Unix-like systems all user specific files and directories are kept in user's home directory which is usually located at the /home/
<<