Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to have multiple versions of Ruby AND Rails, and their combinations on Windows?

Since Windows doesn't support rvm (Ruby version Manager), how do we have

  • Ruby 1.8.7, Rails 2.3.8
  • Ruby 1.8.7, Rails 3.0.0
  • Ruby 1.9.2, Rails 3.0.0

on the same PC? Virtual machines can be used but it is kind of troublesome.

like image 288
nonopolarity Avatar asked Sep 06 '10 02:09

nonopolarity


People also ask

Can you install multiple versions of Ruby?

These allow you to keep multiple versions of Ruby on the same system. Once you've installed a version manager, and installed your own Ruby version, you won't mess with your system's Ruby and its Gems, which is the greatest benefit. No more sudo !

How do I install multiple Rails versions?

There's nothing you need to do to manage two different Rails versions. The only thing you'll want to do is gem install rails to get the latest version and create your new project with rails new myapp . That will make sure the new project starts with Rails 5.1 (or whatever is the latest at the time).


1 Answers

Use uru. It is a multi-platform ruby environment manager. You can download the Windows version here: https://bitbucket.org/jonforums/uru/wiki/Downloads

Install the tool

Assuming C:\tools is on PATH and uru_rt.exe was extracted to C:\tools

C:\tools>uru_rt admin install 

This adds uru.bat file to the tools directory.

Register ruby

uru admin add C:\ruby200\bin 

List available rubies

uru ls 174         : jruby 1.7.4 (1.9.3p392) 2013-05-16 2390d3b on Java HotSpot(TM) 200p255     : ruby 2.0.0p255 (2013-07-07 revision 41812) [i686-linux] => system   : ruby 2.1.0dev (2013-07-06 trunk 41808) [i686-linux] 

Switch ruby version

uru 174 ---> Now using jruby 1.7.4 tagged as `174` 

More commands can be found here: https://bitbucket.org/jonforums/uru/wiki/Examples


Old answer

I use Pik to manage multiple versions of ruby on a Windows machine.

Install the pik gem

> gem install pik Successfully installed pik-0.2.6 1 gem installed 

Install pik to a location that’s in your path, but someplace other than your ruby\bin dir.

>echo %path% PATH=c:\pik;c:\ruby\Ruby187\bin;  >pik_install C:\pik Thank you for using pik.  Installing to C:\pik pik is installed 

Install Ruby 1.9.2 using RubyInstaller and add the new Ruby version to pik registry.

>pik add C:\Ruby192\bin 

List the available Ruby versions:

>pik list 187: ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mingw32] * 192: ruby 1.9.2p0 (2010-08-18) [i386-mingw32] 

To switch to Ruby 1.9.2:

>pik 192 >pik list 187: ruby 1.8.7 (2010-01-10 patchlevel 249) [i386-mingw32] 192: ruby 1.9.2p0 (2010-08-18) [i386-mingw32] * 

To switch between different versions of Rails:

In Rails 2.x, set the RAILS_GEM_VERSION in config/environment.rb file:

RAILS_GEM_VERSION = '= 2.3.8' unless defined? RAILS_GEM_VERSION 

In rails 3, use the Gemfile to specify the Rails version:

gem "rails", "3.0.0" 
like image 96
Harish Shetty Avatar answered Sep 17 '22 05:09

Harish Shetty