开发者

Unable to require RubyGems

I have RubyGems version 1.8.5 and Ruby version 1.8.7. My problem is that even after installing gems I am not able to require it. On the command line typing gem list --local gives:

bundler (1.0.15)
hpricot (0.8.4)
json (1.5.1)开发者_开发问答
redcarpet (1.17.1)

But this does not help.

begin
    require 'bundler'
    rescue LoadError => boom
        warn "Bundler not found"
    exit 0
end
# I get Bundler not found

I am running Ubuntu Natty 32-bit

UPDATE: After requiring RubyGems in irb I get a much informable error i.e.

LoadError: no such file to load -- bundler
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /usr/local/lib/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
from (irb):3
from :0


Bundler does not provide bundler as a file you require directly. Instead you have to require bundler/setup, as shown in the documentation:

http://gembundler.com/

require "rubygems"
require "bundler/setup"

# require your gems as usual
require "nokogiri"

Also, on Ruby 1.8.7, you still need to require 'rubygems'

Hope that helps


Are you sure you've loaded rubygems? What happens when you enter an irb session and type require 'rubygems'?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜