在安装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(bundle update rake),我会得到相同的错误,除了它们现在引用rake的0.9.2而不是0.8.7 .
4 回答
安装新的ruby版本后,您需要运行
rbenv rehash
. 接下来,运行gem install rake
然后第二次运行rbenv rehash
,因为rake安装了二进制文件 .根本原因是gem文件,它仍然引用
ruby-debug
. 将其更改为ruby-debug19
,执行了bundle install
和bundle update
,现在rake工作正常 . 无法解释为什么应用程序在引用ruby-debug时运行正常 .我有同样的问题 . 我的问题的原因是除了在rbenv中的shims目录之外,还在
/usr/bin/local/
中找到了Rake . 要检查这是否是问题首先卸载rakegem uninstall rake
然后运行which rake
. 如果您返回的路径与/Users/username/.rbenv/shims/rake
不同,则只需使用sudo rm /path/to/file
删除该二进制文件 .请注意,至少在我的情况下,
which gem
使用的是由rbenv管理的shimed可执行文件,而rake则不是 . 所以一切都有效,直到我试图从终端调用rake command
.您应该尝试使用chruby而不是rbenv . 与rbenv不同,chruby不依赖于垫片;所以不必再一直运行
rehash
. 相反,chruby仅修改PATH
,GEM_HOME
和GEM_PATH
.