bundle update rake not fixing my 'You have alr

2019-08-23 01:33发布

问题:

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.

回答1:

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

bundle exec rake db:migrate


回答2:

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.