Search code examples
ruby-on-railsrubyruby-on-rails-3pik

rails server command not working and no gems on another version of ruby


i'm running rails on a windows 7 machine and am using pik as my RVM.

i have ruby 1.9.3 currently installed but i have a project that requires ruby 1.9.2.

so using pik, i run these commands from gitbash:

  1. pik 192
  2. ruby -v

ruby 1.9.2p180 (2011-02-18) [i386-mingw32]

  1. rails server

sh.exe": rails: command not found

however, when i use pik 193 i can definitely see the server running. running gem list under pik 192 also does not display any local gems while pik 193 displays a lot of them.

how do i "share" the gems between these 2 version or is there a better option that will be less risky?


Solution

  • To share gems across installations, you need to install the gems in a common place to the two installations.

    By default, Ruby on Windows will install gems inside the directory of Ruby.

    You can verify this by doing:

    gem env gemdir
    

    To install in a common place for both interpreters, you will need to set GEM_HOME environment variable to a specific directory, like C:\gems

    SET GEM_HOME=C:\gems
    gem env gemdir
    

    You will also require to add the bin directory to the PATH:

    SET PATH=C:\gems\bin;%PATH%
    

    That will allow gems executables be available.

    However, please note that while Ruby 1.9.2 and 1.9.3 state they are compatibles, is might not be true for compiled C extensions that are part of some gems.

    Ruby 1.9.3 introduced certain API-level functions that are not available in 1.9.2 and that can cause issues when a 1.9.3-compiled gem is loaded in Ruby 1.9.2

    These differences can cause segmentation fault and weird application crashes in some cases.

    It is not recommended, so use at your own risk.

    Hope that helps.