0

当我rake db:migrate在 Ubuntu 终端中运行时,我不断收到错误消息:

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

我在stackoverflow上看到解决这个问题的一种方法是运行:

bundle update rake

所以我这样做,我得到:

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.

这不应该将 rake 更新到 10.0.4 吗?因为当我运行时,rake db:migrate我仍然得到错误:

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

有什么想法可以解决这个问题吗?当我跑步时,gem env我得到:

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/

会不会与 GEM PATHS 有冲突?谢谢你的帮助。

4

2 回答 2

3

我总是建议在任何此类命令之前使用“bundle exec”

bundle exec rake db:migrate
于 2013-07-30T10:10:29.317 回答
1

您已将您的问题标记为rvm- 所以我假设您使用 RVM,但您的 gem env 看起来不像您使用 rvm 安装的 ruby​​,为此您需要运行:

rvm use ruby --version
bundle install

rvm 默认情况下带有rubygems-bundlergem,它会bundle exec为您自动执行,所以它应该足以:

rake db:migrate

使用 rvm 安装 ruby​​ 后,使 ruby​​ 默认为下一个会话运行:

rvm use ruby --default

在极少数情况下(如系统安装或 osx),您需要重新启动计算机才能使其生效。

于 2013-07-30T17:36:50.533 回答