Thursday, September 15, 2011

Managing multiple version of Ruby and Rails in Windows: PIK

Here I will give a breif description about a tool called Pik (https://github.com/vertiginous/pik), a ruby version manager for Windows.


With the help of Pik, one can have multiple version of Ruby and Rails in his system. Find below the steps that are required for installing Pik:


1. Go to RubyForge and download Ruby. If Ruby is already present, then skip step 1.
2. For installing pik, run the following command from your terminal. gem install pik. You should see ‘Successfully installed pik-0.2.8‘ message soon enough
3. After downloading this gem, you will need to intall pik in some directory other than "C:\Ruby\bin". You can perform the following steps:
    a. d:
    b. mkdir pik
    c. Include the newly created directory, i.e D:\pik in the PATH environment variable.
    d. pik_install D:\pik
Pik will be now installed in your system.



Using Pik


I can now start using Pik for mantaining multiple versions of Ruby and Rails !!.


>pik
** Adding:  187: ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-mingw32]
Located at:  C:\Ruby187\bin
Usage: pik command [options]

Executing pik list outputs all the ruby installations it knows about. 



>pik list
* 187: ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-mingw32]
  192: ruby 1.9.2p290 (2011-07-09) [i386-mingw32]
 
As Rails 3.0 requires 1.8.7 or higher, let’s install the latest version of Ruby.



You can then switch to the particular version you want, for example originally I was running 1.8.7.


>ruby -v
ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-mingw32]

But I can then switch to 1.9.2 with a simple command.



>pik switch 192

>ruby -v
ruby 1.9.2p290 (2011-07-09) [i386-mingw32]


Now by switching the versions of ruby we can install and have different rails version. For example with ruby version 1.8.7, I can have rails 2.3.8 version and I can have rails 3.0 version by switching the ruby version to 1.9.2 !!



No comments:

Post a Comment