尝试运行rake db:migrate时出错

时间:2012-05-23 04:16:56

标签: ruby-on-rails ruby ruby-on-rails-3

当我尝试命令rake db:migrate

时,我收到以下错误
> NOTE: Gem.source_index is deprecated, use Specification. It will be
> removed on or after 2011-11-01. Gem.source_index called from
> /home/hilarl/workspace/depot/vendor/rails/railties/lib/rails/gem_dependency.rb:21.
> NOTE: Gem::SourceIndex#initialize is deprecated with no replacement.
> It will be removed on or after 2011-11-01. Gem::SourceIndex#initialize
> called from
> /home/hilarl/workspace/depot/vendor/rails/railties/lib/rails/vendor_gem_source_index.rb:100.
> NOTE: Gem::SourceIndex#add_spec is deprecated, use
> Specification.add_spec. It will be removed on or after 2011-11-01.
> Gem::SourceIndex#add_spec called from
> /home/hilarl/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:91.
> NOTE: Gem::SourceIndex#add_spec is deprecated, use
> Specification.add_spec. It will be removed on or after 2011-11-01.
> Gem::SourceIndex#add_spec called from
> /home/hilarl/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:91.
> NOTE: Gem::SourceIndex#add_spec is deprecated, use
> Specification.add_spec. It will be removed on or after 2011-11-01.
> Gem::SourceIndex#add_spec called from
> /home/hilarl/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:91.
> NOTE: Gem::SourceIndex#add_spec is deprecated, use
> Specification.add_spec. It will be removed on or after 2011-11-01.
> Gem::SourceIndex#add_spec called from
> /home/hilarl/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:91.
> NOTE: Gem::SourceIndex#add_spec is deprecated, use
> Specification.add_spec. It will be removed on or after 2011-11-01.
> Gem::SourceIndex#add_spec called from
> /home/hilarl/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:91.
> NOTE: Gem::SourceIndex#add_spec is deprecated, use
> Specification.add_spec. It will be removed on or after 2011-11-01.
> Gem::SourceIndex#add_spec called from
> /home/hilarl/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/source_index.rb:91.
> WARNING: 'require 'rake/rdoctask'' is deprecated.  Please use 'require
> 'rdoc/task' (in RDoc 2.4.2+)' instead.
>     at /home/hilarl/.rvm/gems/ruby-1.9.3-p194@global/gems/rake-0.9.2.2/lib/rake/rdoctask.rb
> rake aborted! can't activate activesupport-3.2.3, already activated
> activesupport-2.3.14
> 
> (See full trace by running task with --trace)

知道为什么会这样吗?我正在使用ubuntu,我的系统上安装了ruby 1.9.3-p194和rails 2.3.14并使用了sqlite3

2 个答案:

答案 0 :(得分:1)

你能试试吗

bundle exec rake db:migrate

您可以在系统中安装相同gem的不同版本 - 因此 bundle exec <command> 使用其版本与项目Gemfile绑定的gem(在Gemfile.lock文件中搜索您的gem以查看哪个版本正在使用)。

更好的做法是创建gemsets来打包选择的gems版本,这些版本将根据上下文中的项目激活。

http://bcardarella.com/post/699582642/rvm-gemsets-bundler-awesome

答案 1 :(得分:1)

检查已安装的导轨版本:

$ gem list rails

*** LOCAL GEMS ***

rails (3.2.3, 2.3.14)

你应该有多个像我在这里做的3.2.3和2.3.14

之后卸载你不需要的:

$ gem uninstall rails -v2.3.14
Remove executables:
    rails

in addition to the gem? [Yn]  Y
Removing rails
Successfully uninstalled rails-2.3.14

最后你应该只有一个版本的rails:

$ gem list rails

*** LOCAL GEMS ***

rails (3.2.3)