rake安装失败但gem安装正常

时间:2016-06-20 13:22:05

标签: ruby rubygems rake bundle

bundle exec rake install失败,但gem install有效。如何解决问题?

我发现了类似的问题,他通过在puts out中添加install gem method来解决问题。我做了同样的事,但错误消息只是指示nil。to_s被调用。

rake install fails but gem install works fine, any idea why?

错误消息

be rake install --trace
** Invoke install (first_time)
** Invoke build (first_time)
** Execute build
gnf 0.1.2 built to pkg/gnf-0.1.2.gem.
** Execute install
ERROR:  While executing gem ... (TypeError)
    no implicit conversion of nil into String
rake aborted!
Couldn't install gem, run `gem install /Users/ironsand/dev/gnf/pkg/gnf-0.1.2.gem' for more detailed output
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.3/lib/bundler/gem_helper.rb:88:in `install_gem'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.3/lib/bundler/gem_helper.rb:44:in `block in install'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:240:in `call'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:240:in `block in execute'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:235:in `each'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/task.rb:165:in `invoke'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:150:in `invoke_task'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:106:in `block (2 levels) in top_level'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:106:in `each'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:106:in `block in top_level'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:115:in `run_with_threads'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:100:in `top_level'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:78:in `block in run'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:176:in `standard_exception_handling'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/2.2.0/rake/application.rb:75:in `run'
/Users/ironsand/.rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/rake-10.4.2/bin/rake:33:in `<top (required)>'
/Users/ironsand/.rbenv/versions/2.2.2/bin/rake:23:in `load'
/Users/ironsand/.rbenv/versions/2.2.2/bin/rake:23:in `<main>'
Tasks: TOP => install

gem install

命令没有错误:

gem install /Users/ironsand/dev/gnf/pkg/gnf-0.1.2.gem

gnf.gemspec

编码:utf-8

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

Gem::Specification.new do |spec|
  spec.name          = 'gnf'
  spec.version       = GNF::VERSION
  spec.authors       = ['ironsand']
  spec.email         = ['ironsand@example.com']
  spec.licenses      = ['MIT']

  spec.summary       = %q{GFN}
  spec.description   = %q{GFN}
  spec.homepage      = 'http://github.com/ironsand/foobar'

  # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
  # delete this section to allow pushing this gem to any host.
  if spec.respond_to?(:metadata)
    spec.metadata['allowed_push_host'] = 'http://mygemserver.com'
  else
    raise 'RubyGems 2.0 or newer is required to protect against public gem pushes.'
  end

  spec.files         = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
  spec.bindir        = 'exe'
  spec.executables   = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
  spec.require_paths = ['lib']

  spec.add_development_dependency 'bundler', '~> 1.10'
  spec.add_development_dependency 'rake', '~> 10.0'
  spec.add_development_dependency 'rspec'
  spec.add_dependency 'selenium-webdriver'
end

环境

 % rake --version
rake, version 11.1.2
 % bundle --version
Bundler version 1.10.3
 % ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin13]

有什么原因导致此错误吗?

1 个答案:

答案 0 :(得分:0)

我不确定导致此错误的原因,但通过更新我的宝石版本,错误不再发生。