在安装了Rbenv和Ruby 1.9.2和1.8.7,并将当前项目设置为使用1.9.2 (之前使用的是1.8.7)之后,Rake将不再运行。运行rake routes
会显示以下消息:
Could not find rake-0.8.7 in any of the sources
Run `bundle install` to install missing gems.
这是在运行bundle install
之后执行的。
尝试bundle exec rake routes
(这是安装Rbenv之前使用的方法)会产生以下错误:
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /Library/Ruby/Gems/1.8/gems/bundler-1.0.9/lib/bundler/shared_helpers.rb:3.
Invalid gemspec in [/Users/jackrg/Documents/Novelty-Stats/vendor/local/ruby/1.8/specifications/jquery-rails-1.0.19.gemspec]: invalid date format in specification: "2011-11-26 00:00:00.000000000Z"
Invalid gemspec in [/Users/jackrg/Documents/Novelty-Stats/vendor/local/ruby/1.8/specifications/tilt-1.3.3.gemspec]: invalid date format in specification: "2011-08-25 00:00:00.000000000Z"
NOTE: Gem.source_index is deprecated, use Specification. It will be removed on or after 2011-11-01.
Gem.source_index called from /Library/Ruby/Gems/1.8/gems/bundler-1.0.9/lib/bundler/source.rb:161.
NOTE: Gem::SourceIndex#each is deprecated with no replacement. It will be removed on or after 2011-11-01.
Gem::SourceIndex#each called from /Library/Ruby/Gems/1.8/gems/bundler-1.0.9/lib/bundler/source.rb:161.
Could not find rake-0.8.7 in any of the sources
请注意,应用程序本身在开发(rails c
、rails s
等)过程中运行时没有问题。
还要注意,gem list
将rake (0.8.7)列为本地gem。
如果我将gemfile更改为请求rake版本0.9.2,然后更新包(bundle update rake),我会得到相同的错误,只是它们现在引用的是rake版本0.9.2而不是0.8.7。
发布于 2012-03-16 09:54:09
根本原因是gem文件,它仍然引用ruby-debug
。将其更改为ruby-debug19
,执行了bundle install
和bundle update
,现在rake工作得很好。无法解释为什么引用ruby-debug时应用程序运行正常。
发布于 2012-03-15 23:18:40
安装新的ruby版本后,您将需要运行rbenv rehash
。接下来,运行gem install rake
,然后在rbenv rehash
安装二进制文件时再次运行rake。
发布于 2014-01-10 09:07:29
我也有同样的问题。我出现问题的原因是,除了在rbenv的shims目录中,还在/usr/bin/local/
中找到了Rake。要检查这是否是问题所在,请先卸载rake gem uninstall rake
,然后运行which rake
。如果您返回的路径与/Users/username/.rbenv/shims/rake
不同,则只需使用sudo rm /path/to/file
删除该二进制文件。
请注意,至少在我的例子中,which gem
使用的是由rbenv管理的填充式可执行文件,而rake不是,所以在我尝试从终端调用rake command
之前,find一切正常。
https://stackoverflow.com/questions/9694219
复制相似问题