Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Use pik in Windows

    • 0
    • 3
    • 3
    • 1
    • 0
    • 0
    • 0
    • 0
    • 936
    Comment on it

    Managing multiple versions of Ruby on Windows can be a harrowing task since RVM is not present for Windows environment. And suppose you want to install different projects which require different version of Ruby and Rails on Windows.

    Can be a challenging task? I don't think so as pik comes to your rescue.

    "pik is a tool to manage multiple versions of ruby on Windows. It can be used from the Windows command line (cmd.exe), Windows PowerShell, or Git Bash."

    Installation can be tricky at times. So I will take you through a simple tutorial of installing pik and managing your ruby versions.

    First and foremost, install which ever ruby versions you require on your system from -

    http://rubyinstaller.org/downloads/

    It contains the various version of ruby installers.

    While installing Ruby do select
    Add ruby executables to your PATH

    This ensures that you are able to execute ruby files from any directory.

    Generally Ruby is installed by default in Drive C if the user did not change the path and the folder name is usually by the name of Rubyversion. (p.s ignoring the dots in between)

    For example if you installed Ruby version 2.0.0 then the ruby folder would be by the name of Ruby200.

    Then head to

    https://github.com/vertiginous/pik/downloads

    to download the pik installer. Install pik without changing any options to avoid confusions.

    You will also need to install DevKit from

    http://rubyinstaller.org/downloads/

    "The RubyInstaller Development Kit is a toolkit that makes it easy to build and use native C/C++ extensions such as RDiscount and RedCloth for Ruby on Windows."

    Install DevKit and change directory to the installed location from the terminal.

    cd <DEVKIT_INSTALLATION_DIRECTORY> 
    

    Then execute the following

    ruby dk.rb init
    

    This generates a config.yml file. It contains the installed ruby versions.

    Open this config.yml file in a text editor present at

    C:\Documents and Settings\user\.pik\config.yml

    Note- Here user would be the current user's name. For example on my system the current user is anirudh so the path would be

    C:\Documents and Settings\anirudh\.pik\config.yml

    The file would contain something like this

    --- 
    "187: ruby 1.8.7p374 (2013-06-27) [i386-mingw32]": 
      :path: !ruby/object:Pathname 
        path: C:/Ruby187/bin
    "193: ruby 1.9.3p448 (2013-06-27) [i386-mingw32]": 
      :path: !ruby/object:Pathname 
        path: C:/Ruby193/bin
    --- {}
    

    You can also add a Ruby version if missing. For example I added below one more ruby version

    --- 
    "187: ruby 1.8.7p374 (2013-06-27) [i386-mingw32]": 
      :path: !ruby/object:Pathname 
        path: C:/Ruby187/bin
    "193: ruby 1.9.3p448 (2013-06-27) [i386-mingw32]": 
      :path: !ruby/object:Pathname 
        path: C:/Ruby193/bin
    "200: ruby 2.0.0.p353 (2013-06-27) [i386-mingw32]": 
      :path: !ruby/object:Pathname 
        path: C:/Ruby200/bin
    --- {}
    

    Here the number 187 , 193 or 200 are the ruby versions minus dots.

    To verify the changes done to the config.yml file and whether they are correct or not execute the following

    ruby dk.rb review
    

    Finally,

    ruby dk.rb install
    

    It enhances your installed Rubies.

    According to DevKit website this step installs (or updates) an operatingsystem.rb file into the relevant directory needed to implement a RubyGems preinstall hook and a devkit.rb helper library file into \lib\ruby\site_ruby

    Now you are ready to use multiple versions of Ruby in Windows To view the installed ruby versions execute

    pik list
    

    To view pik commands execute

    pik help commands
    

    On my machine pik list shows the following

    187: ruby 1.8.7p374 (2013-06-27) i386-mingw32
    193: ruby 1.9.3p448 (2013-06-27) i386-mingw32
    200: ruby 2.0.0.p353 (2013-06-27) i386-mingw32
    

    Now to use ruby version 1.9.3 I would use the command

    pik 193
    

    Same is the case for ruby 1.8.7

    pik 187
    

    Once you start using the required ruby version you can install multiple version of rails as well. Hope this helps in sorting out problems faced on windows system when using pik.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: