安装rbenv并更改Ruby版本后,Rake不再运行



安装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 crails s等)

还要注意,gem list将rake(0.8.7)列为局部gem。

如果我将gemfile更改为请求rake版本0.9.2,然后更新bundle(bundle update rake),我会得到相同的错误,只是它们现在引用的是rake版本0.9.2,而不是0.8.7。

安装新的ruby版本后,您需要运行rbenv rehash。接下来,运行gem install rake,然后在rake安装二进制文件时再次运行rbenv rehash

根本原因是gem文件,它仍然引用ruby-debug。将其更改为ruby-debug19,做了bundle installbundle update,现在rake工作正常。无法解释为什么应用程序在引用ruby调试时运行良好。

我也遇到了同样的问题。我的问题的原因是,除了在rbenv的垫片目录中之外,在/usr/bin/local/中也发现了Rake。要检查是否存在此问题,请先卸载rake gem 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不依赖垫片;因此不再需要一直运行CCD_ 21。相反,chruby只修改PATHGEM_HOMEGEM_PATH

最新更新