Monday, October 8, 2012

Maintaining multiple ruby and ruby gems version in windows

I've two different gem repository 1.8.7 and 1.9.1. However ruby gem environment uses only one gem repository for all uninstall and update commands (which can be retrieved using GEM ENV) command. But because of this I was somewhat helpless for uninstalling/modifying the gems in repository different from the default one. Use the following steps to control the same:

Maintaining multiple ruby version: PiK is a very helpful gem to maintain multiple ruby versions on your machine. You can add references of all ruby versions available in system and select which one to use by default i.e. updating Gem environment.
a) Install Pik gem: Open command prompt with ruby and rails (type ruby in search box on windows)
gem install pik
b)  Then add the bin path of all ruby versions available like:
pik add C:\RailsInstallerNew\Ruby1.9.3\bin
 c) Now run "$ pik list" command to verify all ruby versions added to pik. Also notice there will be a unique number in the starting of each ruby instance like 187, 193 (which references the ruby versions).

d) To select a particular ruby version use "pik <unique number mentioned in point c>" like
pik 187
After this command if you fire pik list command then you'll see a * in front of ruby 187 version. Also "$ gem env" command will show ruby version 1.8.7 as the default version selected.

Maintaining multiple gem set with multiple ruby versions (not sure): In case of multiple gem directory and uninstalling a particular gem version (from the gemset different from the default gem repository) first go to the gem bin directory of that particular ruby version (from the cmd) and then fire run "gem uninstall <gemname>".

No comments:

Post a Comment