【发布时间】:2012-03-14 00:21:46
【问题描述】:
安装 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,然后更新捆绑包(捆绑更新 rake),我会得到相同的错误,除了它们现在引用 rake 的版本 0.9.2 而不是 0.8.7。
【问题讨论】:
-
你在安装 rubies 后运行
rbenv rehash了吗?另外,您是否按照说明将 shims 目录添加到您的路径? -
我做了
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile,然后是exec $SHELL,如 Sam Stephenson 关于安装 rbenv 的文档的第 2.1 节的第 3 和第 4 步中所述,如果这就是你的意思。我不知道启用垫片的任何其他步骤。是否有独立的方法来测试垫片是否启用?
标签: ruby-on-rails rake bundler rbenv