简体   繁体   中英

can't get ruby 1.8.7 to work after installing 1.9.2

I installed ruby 1.9.2 via one click installer on windows 7.

Now I have a gem that only runs on 1.8.7

So I installed Pik and am trying to get 1.8.7 working.

irb runs fine, but require does not.

For example if I do a gem list it lists the gem in question When I require the gem in irb it says no such file to load.

When I use Pik to switch back to 1.9.2 all is well (ie the gem loads)

I have tried loading the gems outside of pik and inside of pik.

here is my load path running under 1.8.7:

....>ruby -ve "puts $LOAD_PATH.inspect"
ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-mingw32]
["C:/Ruby187/lib/ruby/site_ruby/1.8", "C:/Ruby187/lib/ruby/site_ruby/1.8/i386-ms
vcrt", "C:/Ruby187/lib/ruby/site_ruby", "C:/Ruby187/lib/ruby/vendor_ruby/1.8", "
C:/Ruby187/lib/ruby/vendor_ruby/1.8/i386-msvcrt", "C:/Ruby187/lib/ruby/vendor_ru
by", "C:/Ruby187/lib/ruby/1.8", "C:/Ruby187/lib/ruby/1.8/i386-mingw32", "."]

I do not see Ruby187/lib/ruby/gems/1.8 on the path... perhaps that is the problem? if so how do I fix it (I don't know how to change the load path) and does anybody know why pik is not working or what I could do to fix.

In the end, does anybody know just how to get rid of 1.9.2, and do a clean install of 1.8.7?

Thanks for any help!

While RubyInstaller include RubyGems with the package, Ruby 1.8.x itself does not activate RubyGems by default like 1.9.1 and 1.9.2 do.

You need to require "rubygems" before doing require to any of the gems you want to load.

Since your script can work on both versions of Ruby, you can do something like this:

require "rubygems" unless defined?(Gem)

Which will enable RubyGems if is not defined (which is under Ruby 1.9.2)

Hope that helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM