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

Ruby on rails 安装rbenv并更改Ruby版本后,Rake不再运行,ruby-on-rails,rake,bundler,rbenv,Ruby On Rails,Rake,Bundler,Rbenv,在安装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 exec rake routes(这是安装Rbenv之前使用的方法),会产生以下错误:

在安装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 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。

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

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

您应该尝试使用而不是rbenv。与rbenv不同,chruby不依赖垫片;这样就不必一直运行
rehash
。相反,chruby只修改
PATH
GEM\u HOME
GEM\u PATH
,我也遇到了同样的问题。我的问题的原因是Rake除了位于rbenv中的shimmes目录之外,还在
/usr/bin/local/
中找到。要检查这是否是问题,请先卸载rake
gem uninstall rake
,然后运行
哪个rake
。如果返回的路径不同于
/Users/username/.rbenv/shimmes/rake
,则只需使用
sudo rm/path/to/file
删除该二进制文件即可


请注意,至少在我的例子中,
哪个gem
使用了由rbenv管理的shimed可执行文件,而rake没有。因此,在我尝试从终端调用
rake命令之前,一切都正常了。

安装rubies后,您是否运行了
rbenv rehash
?另外,您是否遵循了将垫片目录添加到路径的说明?我确实执行了
echo'eval“$(rbenv init-”>~/.bash_profile
,然后是
exec$SHELL
,如Sam Stephenson关于安装rbenv的文档第2.1节第3步和第4步所述,如果这是您的意思的话。我不知道启用垫片的任何其他步骤。是否有独立的方法来测试垫片是否启用?是否有。现在getting
在任何源中都找不到rake-0.9.2
运行“bundle install”来安装缺少的gems。
运行
bundle install
和Get
不幸的是,发生了致命错误。请将此错误报告给Bundler问题跟踪程序,地址为https://github.com/carlhuda/bundler/issues 这样我们就可以修复它了。按要求报告错误。在搜索google后,尝试了
捆绑更新
,该软件在报告安装linecache(0.46)时爆炸,错误为ruby gems/installer.rb(第552行)中的“无法处理1.9.x”。回顾您的第一个错误,有人提到系统ruby(
/Library/ruby/gems/1.8/…
)。我怀疑您可能在第一次重新刷新之前尝试安装了rake,这让事情变得混乱。如果我是您,我会删除
~/.rbenv/versions/1.9.2
目录,然后重新开始。另外,在安装rbenv之后和安装新版本ruby之前,您是否将
eval“$(rbenv init-”
添加到
~/.profile
中?因此,如果我正确理解您的建议,我应该从rbenv中删除ruby 1.9.2目录,重新安装ruby 1.9.2,重新安装,安装rake,然后重新安装。对的我确实在bash启动文件中添加了
rbenv init-
命令。不能保证我是在安装新版本的ruby之前还是之后做的。但是在添加命令(即exec$shell)后,我确实重新启动了shell。