繁体   English   中英

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

[英]After installing rbenv and changing Ruby version, Rake no longer runs

安装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)列为本地宝石。

如果我将gemfile更改为请求rake版本0.9.2,然后更新捆绑软件(捆绑更新rake),则会遇到相同的错误,除了它们现在引用的rake版本为0.9.2,而不是0.8.7。

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

我有同样的问题。 我的问题的原因是,除了在rbenv的shims目录中之外,还在/usr/bin/local/中找到了Rake。 要检查这是否是问题,请先卸载rake gem uninstall rake然后gem uninstall rake然后运行which rake 如果返回的路径不同于/Users/username/.rbenv/shims/rake则只需使用sudo rm /path/to/file删除该二进制sudo rm /path/to/file

请注意,至少就我而言, which gem使用的是由rbenv管理的shimed可执行文件,而rake则不是。 因此,一切正常,直到我尝试从终端调用rake command为止。

根本原因是gem文件,该文件仍引用ruby-debug 将其更改为ruby-debug19 ,进行了bundle installbundle update ,现在rake可以正常工作。 无法通过引用ruby-debug解释为什么应用程序可以正常运行。

您应该尝试使用chruby而不是rbenv。 与rbenv不同,chruby不依赖垫片。 因此不再需要一直进行重新rehash 而是,chruby仅修改PATHGEM_HOMEGEM_PATH

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM