我创建了自己的RubyGem,但当我在本地机器上尝试时,出现了一些烦人的问题。我在谷歌和其他StackOverflow问题中找过,但仍未找到解决此问题的方法。
如果我在irb中使用非root用户,并在输入require 'rubygems'后输入require 'my_own_gem',则会出现以下情况:
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
当使用root用户并通过sudo irb命令时,问题不会出现,一切看起来都很正常。 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("../lib", __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
which ruby
和sudo which ruby
命令。 - d11wtq