2
votes

After installing Rbenv and Ruby 1.9.2 and 1.8.7, and setting the current project to use 1.9.2 (it previously used 1.8.7), Rake will no longer run. Running rake routes gives the messages:

Could not find rake-0.8.7 in any of the sources
Run `bundle install` to install missing gems.

This after runing bundle install.

Trying bundle exec rake routes (which is the method used prior to installing Rbenv), produces the following errors:

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

Note that the application itself runs without issue in development (rails c, rails s, etc.).

Also note that gem list lists rake (0.8.7) as a local gem.

If I change the gemfile to request rake version 0.9.2 and then update the bundle (bundle update rake), I get the same errors except that they now refer to version 0.9.2 of rake instead of 0.8.7.

4
Have you run rbenv rehash after installing the rubies? Also, have you followed instructions on adding the shims directory to your path?aceofspades
I did echo 'eval "$(rbenv init -)"' >> ~/.bash_profile followed by exec $SHELL as described in steps 3 and 4 of Section 2.1 of Sam Stephenson's doc on installing rbenv, if that's what you mean. I'm not aware of any other step to enable the shims. Is there an independent way to test that shims are enabled?Jack R-G

4 Answers

5
votes

After installing the new ruby version, you'll need to run rbenv rehash. Next, run gem install rake then run rbenv rehash a second time as rake installs binaries.

1
votes

Root cause was the gem file, which still referenced ruby-debug. Changed it to ruby-debug19, did a bundle install and a bundle update, and now rake works fine. Can't explain why application ran okay with the reference to ruby-debug.

1
votes

I had the same problem. The cause for my problem was that Rake was also found in /usr/bin/local/ in addition to being in the shims directory in rbenv. To check if this is the problem first uninstall rake gem uninstall rake then run which rake. If you get back a path that is different than /Users/username/.rbenv/shims/rake then just remove that binary using sudo rm /path/to/file.

Note that in my case at least, which gem was using a shimed executable that was managed by rbenv, while rake wasn't. So everything worked find until I tried to invoke rake command from the terminal.

0
votes

You should try using chruby instead of rbenv. Unlike rbenv, chruby does not rely on shims; so no more having to run rehash all the time. Instead, chruby only modifies PATH, GEM_HOME and GEM_PATH.