Bundler"找不到耙子" "在任何来源"

时间:2017-02-27 21:28:16

标签: ruby-on-rails ruby rake bundler

我有一个rake任务,其命名空间包含两个任务startstop。我namespace:stop ped,然后namespace:start再次编辑,然后......捆绑者炸毁了我:

/home/user/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.5/lib/bundler/spec_set.rb:87:in `block in materialize': Could not find rake-12.0.0 in any of the sources (Bundler::GemNotFound)
    from /home/user/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.5/lib/bundler/spec_set.rb:80:in `map!'
    from /home/user/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.5/lib/bundler/spec_set.rb:80:in `materialize'
    from /home/user/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.5/lib/bundler/definition.rb:176:in `specs'
    from /home/user/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.5/lib/bundler/definition.rb:235:in `specs_for'
    from /home/user/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.5/lib/bundler/definition.rb:224:in `requested_specs'
    from /home/user/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:118:in `block in definition_method'
    from /home/user/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.5/lib/bundler/runtime.rb:19:in `setup'
    from /home/user/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.5/lib/bundler.rb:100:in `setup'
    from /home/user/.rvm/gems/ruby-2.4.0/gems/bundler-1.14.5/lib/bundler/setup.rb:20:in `<top (required)>'
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'

bundle install有效,rake, version 12.0.0已安装,rails c启动正常。而Passenger with Apache显示应用程序没有问题。我已经重新安装了rvm,Ruby,Rails等bundle exec rake namespace:startbin\rake namespace:start引发相同的错误消息。

我已将此发布为a bug in bundlerwith environment details),但可能不是错误,而是路径,权限或某些内容的配置问题?

2 个答案:

答案 0 :(得分:1)

请务必在Gemfile所在的目录中通过bundler调用rake:

bundle exec rake namespace:start

它将确保您的捆绑中的宝石可用。

答案 1 :(得分:1)

我终于意识到了我非常愚蠢的错误。希望我的尴尬可以拯救别人的尴尬。我已经遵循一些建议来修复an issue with the gem mini_magick无法调整看起来有点像这样的图像:

$ cat config/environments/production.rb
# ...
ENV['PATH'] = "/usr/bin:#{ENV['PATH']}"

我终于意识到导致这种奇怪的情况:

$ ruby -v
ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
$ irb
2.4.0 :001 > `ruby -v`
 => "ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]\n"
2.4.0 :001 > quit
$ rails c production
Loading production environment (Rails 5.0.1)
2.4.0 :001 > `ruby -v`
 => "ruby 2.0.0p648 (2015-12-16) [x86_64-linux]\n"

正如您所看到的,Rails正在选择不同版本的Ruby - 实际上是系统Ruby,而不是我的RVM管理的Ruby 2.4。

作为参考,对mini_magick问题的修复不会导致Rails选择错误的Ruby版本是symlink mogrify(而不是将该行添加到production.rb):

$ sudo ln -s /usr/bin/mogrify /usr/local/bin/mogrify

(很大程度上从我的GitHub issue response转发。)