1

问题:

我有我正在研究的这颗宝石。尝试在本地安装它以进行一些测试时,rake install构建 gem 后失败。Rake 建议我运行gem install构建的 gem 来调试。令人惊讶的是,gem install pkg/my_gem-x.y.z.gem它就像一个魅力!

知道为什么吗?

一些细节:

耙版本:10.0.3

使用 bundler 版本创建的 Gem:1.2.1

gemspec的内容:

lib = File.expand_path('../lib', __FILE__)
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
require 'my_gem/version'

Gem::Specification.new do |gem|
  gem.name          = "mygem"
  gem.version       = MyGem::VERSION
  gem.authors       = ["Omar Abdel-Wahab"]
  gem.email         = ["me@example.com"]
  gem.description   = %q{bla bla bla}
  gem.summary       = %q{bla bla bla}
  gem.homepage      = "http://github.com/foobar/"

  gem.files         = `git ls-files`.split($/)
  gem.executables   = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
  gem.test_files    = gem.files.grep(%r{^(test|spec|features)/})
  gem.require_paths = ["lib"]

  gem.add_dependency "rails", ">= 3.1"
  gem.add_dependency "jquery-rails"
  gem.add_dependency "twitter-bootstrap-rails", ">= 2.1.0"

  gem.add_development_dependency "bundler", ">= 1.0.0"
  gem.add_development_dependency "rspec", "~> 2.3"
  gem.add_development_dependency "sqlite3-ruby"
end

输出rake install

~/Projects/Github/my_gem% rake -vt install
** Invoke install (first_time)
** Execute install
my_gem 0.0.1 built to pkg/my_gem-0.0.1.gem
rake aborted!
Couldn't install gem, run `gem install /Users/owahab/Projects/Github/my_gem/pkg/my_gem-0.0.1.gem' for more detailed output
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/gems/bundler-1.2.1/lib/bundler/gem_helper.rb:68:in `install_gem'
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/gems/bundler-1.2.1/lib/bundler/gem_helper.rb:43:in `block in install'
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:228:in `call'
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:228:in `block in execute'
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:223:in `each'
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:223:in `execute'
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:166:in `block in invoke_with_call_chain'
/Users/owahab/.rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/monitor.rb:211:in `mon_synchronize'
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:159:in `invoke_with_call_chain'
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/task.rb:152:in `invoke'
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:143:in `invoke_task'
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:101:in `block (2 levels) in top_level'
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:101:in `each'
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:101:in `block in top_level'
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:110:in `run_with_threads'
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:95:in `top_level'
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:73:in `block in run'
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/bin/rake:19:in `load'
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/bin/rake:19:in `<main>'
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/bin/ruby_noexec_wrapper:14:in `eval'
/Users/owahab/.rvm/gems/ruby-1.9.3-p286/bin/ruby_noexec_wrapper:14:in `<main>'
Tasks: TOP => install

rake build从那时起的输出gem install

~/Projects/Github/rails_autocomplete% rake build && gem install pkg/my_gem-0.0.1.gem
my_gem 0.0.1 built to pkg/my_gem-0.0.1.gem
Successfully installed my_gem-0.0.1
1 gem installed
Installing ri documentation for my_gem-0.0.1...
Building YARD (yri) index for my_gem-0.0.1...
Installing RDoc documentation for my_gem-0.0.1...
4

1 回答 1

1

根据该问题的评论线程,这是一个权限问题。调试 Bundler 的gem_helper.rb文件揭示了这一点:

错误:执行 gem 时...(Errno::EACCES)权限被拒绝 - /Users/owahab/.rvm/gems/ruby-1.9.3-p286/gems/i18n-0.6.1/ci/Gemfile.no-rails

一些 gem 已以 root 身份安装。删除它们解决了问题。

于 2013-03-25T13:46:02.667 回答