0

When I run rake db:migrate in Ubuntu Terminal I keep getting the error:

rake aborted!
You have already activated rake 10.0.4, but your Gemfile requires rake 0.9.6. Using bundle exec may solve this.

I saw on stackoverflow a way to solve this problem is to run:

bundle update rake

So I do this and I get:

Fetching gem metadata from https://rubygems.org/.......
Fetching gem metadata from https://rubygems.org/..
Enter your password to install the bundled RubyGems to your system: 
Using rake (0.9.6) 
Using SystemTimer (1.2.3) 
etc...
etc...

    Your bundle is updated! Use `bundle show [gemname]` to see where a bundled gem is installed.

Isn't this supposed to update rake to 10.0.4? Because when I run rake db:migrate I still get the error:

rake aborted!
You have already activated rake 10.0.4, but your Gemfile requires rake 0.9.6. Using bundle exec may solve this.

Any ideas how I can solve this problem? When I run gem env I get:

RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.15
  - RUBY VERSION: 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
  - INSTALLATION DIRECTORY: /var/lib/gems/1.8
  - RUBY EXECUTABLE: /usr/bin/ruby1.8
  - EXECUTABLE DIRECTORY: /usr/local/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /var/lib/gems/1.8
     - /home/mycompaq/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/

Could there be some conflict with the GEM PATHS? Thanks for any help.

CHarris
  • 2,693
  • 8
  • 45
  • 71
  • `Using bundle exec may solve this.` So just use it! `bundle exec rake db:migrate` – Sergey Kishenin Jul 30 '13 at 10:09
  • That was actually one of the first things I tried, but it didn't fix the problem. Shouldn't 'rake -v' simply show you which version of rake you're using? Because when I do rake -v after the bundle exec command I still get: rake aborted! You have already activated rake 10.0.4, but your Gemfile requires.... – CHarris Jul 30 '13 at 10:17
  • 1
    That always happens when your system installed `rake` version differs with project's `rake` version. Try to specify in your `Gemfile` like `gem 'rake', '10.0.4'` or make `0.9.6` version of rake the latest in the system. But actually `bundle exec` is the right solution in such cases as it forcefully uses the version specified in the Gemfile – Sergey Kishenin Jul 30 '13 at 10:20

2 Answers2

3

I always recommend to use "bundle exec" before any such commands

bundle exec rake db:migrate
Said Kaldybaev
  • 9,380
  • 8
  • 36
  • 53
1

you have tagged your question with rvm - so I assume you use RVM, but your gem env does not look like you used rvm installed ruby, to do it you need to run:

rvm use ruby --version
bundle install

rvm by default comes with rubygems-bundler gem which will automate the bundle exec for you so it should be enough to:

rake db:migrate

after rvm installed ruby was used, to make the ruby default for next sessions run:

rvm use ruby --default

in rare cases (like system installation or osx) you need to restart computer for this to take effect.

mpapis
  • 52,729
  • 14
  • 121
  • 158
  • thanks for that, only have the chance to get back to you now. In development mode on my machine I updated my gemfile to 'rake', '~> 10.0.4' and now I can rake:db migrate without errors. But when I try to deploy onto my server with 'cap production deploy:migrations' everything goes fine until 'executing `deploy:assets:precompile' - executing "cd/myapp/releases/20130801221843 && bundle exec rake RAILS_ENV=production RAILS_GROUPS=assets assets:precompile"/servers: ["1.2.3"]/[1.2.3] executing command/[out :: 1.2.3] rake aborted!/[out :: 1.2.3] – CHarris Aug 01 '13 at 23:29
  • Received wrong number of arguments. [nil]/** [out :: 1.2.3] /var/www/apps/myapp/shared/bundle/ruby/1.8/gems/omniauth-1.1.0/lib/omniauth/strategy.rb:136:in `initialize'..etc..with lots of other [out :: 1.2.3] stuff. Also, when I run 'rake assets:precompile' on my local machine I get 'rake aborted! Received wrong number of arguments. [nil] /var/lib/gems/1.8/gems/omniauth-1.1.0/lib/omniauth/strategy.rb:136:in `initialize'. Might be a long shot but, any idea how to fix this, or where to start looking? In any case, thanks. – CHarris Aug 01 '13 at 23:35
  • check this answer http://stackoverflow.com/questions/17810552/rvm-and-gems-bundle-show-and-gem-list/17811625#17811625 - if you still can not fix your problem open a new question with new details of your problem – mpapis Aug 01 '13 at 23:38