Failed to load ruby gem, using require method in IRB
i've created my own rubygem, but when i try in my local machine, there were something annoying, i've been around in google and another StackOverflow question but still not found the solution about this problem.
If i use non-root user in irb and type require 'my_own_gem' after type require 'rubygems' i've got :
LoadError: no such file to load -- my_own_gem
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
from /usr/lib/ruby/1.8/rubygems/custom_require.rb:36:in `require'
from (irb):2
from (null):0
But when using root user, with sudo irb, the problem isn't seen and everything look OK.
gem list -d my_own_gem
my_own_gem (0.0.1)
Author: Jane Doe
Rubyforge: http://rubyforge.org/projects/my_own_gem
Homepage: google.com
Installed at: /var/lib/gems/1.8
lorem ipsum dolor sit amet
gem env
RubyGems Environment:
- RUBYGEMS VERSION: 1.3.7
- RUBY VERSION: 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]
- INSTALLATION DIRECTORY: /var/lib/gems/1.8
- RUBY EXECUTABLE: /usr/bin/ruby1.8
- EXECUTABLE DIRECTORY: /var/lib/gems/1.8/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /var/lib/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
.bashrc
export GEM_HOME=/var/lib/gems/1.8
export GEM_PATH=/var/lib/gems/1.8
my_own_gem.gemspec
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../li开发者_开发问答b", __FILE__)
require "my_own_gem/version"
Gem::Specification.new do |s|
s.name = "my_own_gem"
s.version = MyOwnGem::VERSION
s.platform = Gem::Platform::RUBY
s.authors = ["Jane Doe"]
s.email = ["j4n3d0e@gmail.com"]
s.extra_rdoc_files = ["MIT-LICENSE","README.rdoc"]
s.rdoc_options = ["--charset=UTF-8"]
s.homepage = "google.com"
s.summary = %q{lorem ipsum}
s.description = %q{lorem ipsum dolor sit amet}
s.date = Time.now.utc.strftime("%A, %d% %B %Y")
s.rubyforge_project = "my_own_gem"
s.add_dependency "httparty", "= 0.7.8"
s.post_install_message = "my own gem"
s.files = `git ls-files`.split("\n")
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
s.require_paths = ["lib"]
end
Try add to your .bashrc file
export RUBYOPT="rubygems"
or try to install your gem to /usr/lib/ruby/gems/1.8/......
精彩评论