2

安装 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,然后更新捆绑包(捆绑更新 rake),我会得到相同的错误,只是它们现在引用 rake 的版本 0.9.2 而不是 0.8.7。

4

4 回答 4

5

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

于 2012-03-15T15:18:40.200 回答
1

我有同样的问题。/usr/bin/local/我的问题的原因是除了在 r​​benv 的 shims 目录中之外,还发现了 Rake 。要检查这是否是问题首先卸载 rakegem uninstall rake然后运行which rake。如果您返回的路径与此路径不同,/Users/username/.rbenv/shims/rake则只需使用sudo rm /path/to/file.

请注意,至少在我的情况下,which gem使用的是由 rbenv 管理的 shimed 可执行文件,而 rake 不是。所以一切正常,直到我尝试rake command从终端调用。

于 2014-01-10T01:07:28.877 回答
1

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

于 2012-03-16T01:54:09.240 回答
0

您应该尝试使用chruby而不是 rbenv。与 rbenv 不同,chruby 不依赖 shims;所以不再需要一直运行rehash。相反,chruby 只修改PATH,GEM_HOMEGEM_PATH.

于 2012-11-21T07:38:10.880 回答