Вы находитесь на странице: 1из 3

William Notowidagdo

Kiranatama Staff
Knowledge
ruby, windows
Ruby version manager is a great tool that allows you to easily have multiple versions of Ruby. For Unix-based environment, there is RVM and for Windows we
have Pik. This post will take you to have a quick look on Pik.
Installation
When writing this post I am using ruby 1.9.1p429 (2010-07-02 revision 28523) [i386-mingw32] on Windows 7. You can use Pik from the Windows command
line, Windows PowerShell, or Git Bash. Here I am using the command line. You can install pik via rubygems, or the Windows installer, or you can update pik
with pik. Let us install pik using rubygems
gem install pik
If the installation gone smooth, you should see
Successfully installed pik-0.2.8
1 gem installed
After pik is installed now you want to use pik_install script to install the pik executable. You must install pik to a location in your path, but not in your
Ruby bin directory. I add C:\bin to my path, so I run
pik_install C:\bin
then you should see
pik is installed
if you want to use pik with git bash, add the following line to your ~/.bashrc:
[[ -s $USERPROFILE/.pik/.pikrc ]] && source $USERPROFILE/.pik/.pikrc
Update: the command prompt from which you run pik has to be started using run as Administrator (if its Windows 7). Pik is modifying %PATH% environment
variable and Windows 7 would silently not let it do so if not enough user privileges. Now for the first time run
pik
and pik will print some message and at the top of the message you should see that pik was adding your current Ruby version
** Adding: 191: ruby 1.9.1p429 (2010-07-02 revision 28523) [i386-mingw32]
Located at: C:\Ruby191\bin
...
Usage
To list all available pik commands, simply run
pik help commands
In this post I will show you how to add and use another Ruby version and how to handle gem
How to add and use another Ruby version
Lets start with installing another Ruby version, I am installing Ruby 1.8.7 using rubyinstaller-1.8.7-p299.exe from RubyInstaller for Windows. During the
installation, I was not mark the Add Ruby executables to your PATH option checked. After the install was done, I run
ruby -v
and see that Windows still using 1.9.1 version instead of 1.8.7. Now lets add 1.8.7 to pik
pik add C:\Ruby187\bin
** Adding: 187: ruby 1.8.7 (2010-06-23 patchlevel 299) [i386-mingw32]
Located at: C:\Ruby187\bin
Now run
pik list
to list available Ruby versions
Tweet Tweet 1

Ruby version manager for Windows
28 Jul 2010
Ruby version manager for Windows Ruby on Rails Outsourcing 6/7/2014
http://www.ruby-on-rails-outsourcing.com/articles/2010/07/28/ruby-version-manager-for-windows/ 1 / 3
to list available Ruby versions
187: ruby 1.8.7 (2010-06-23 patchlevel 299) [i386-mingw32]
* 191: ruby 1.9.1p429 (2010-07-02 revision 28523) [i386-mingw32]
the * before 191 means that we are using Ruby 1.9.1 at the moment. Now lets switch to Ruby 1.8.7
pik use 187
and then when you run "pik list" or "ruby -v" you will notice that we are using Ruby 1.8.7 instead of 1.9.1
How to handle gem
Before I install pik, I already install some gems (on Ruby 1.9.1) and when I switch to 1.8.7, gem list doesnt recognize any gem installed previously (since its
in different directory). Using pik you can install gem that will available on every Ruby versions on your environment
pik gem install win32console
now you should have win32console gem available on both versions or Ruby
ruby 1.8.7 (2010-06-23 patchlevel 299) [i386-mingw32]
Successfully installed win32console-1.3.0-x86-mingw32
1 gem installed
ruby 1.9.1p429 (2010-07-02 revision 28523) [i386-mingw32]
Successfully installed win32console-1.3.0-x86-mingw32
1 gem installed
Well, there you go, were now set up with multiple Rubies, just imagine the fun we can have :)
Ruby version manager for Windows Ruby on Rails Outsourcing 6/7/2014
http://www.ruby-on-rails-outsourcing.com/articles/2010/07/28/ruby-version-manager-for-windows/ 2 / 3
Ruby version manager for Windows Ruby on Rails Outsourcing 6/7/2014
http://www.ruby-on-rails-outsourcing.com/articles/2010/07/28/ruby-version-manager-for-windows/ 3 / 3

Вам также может понравиться