Ruby on Rails - rake db:migrate产生错误:“Rake Aborted!未初始化的常量Bundler”

时间:2011-04-09 14:07:26

标签: ruby-on-rails rake bundler abort

我是一个全新的Ruby& Rails程序员。 当我第一次尝试运行rake时:

$ rake db:migrate

我收到此错误:

Rake Aborted!
Uninitialized constant Bundler

环顾四周&谷歌搜索,我不知道该怎么办。类似问题的“答案”之一是:“哦,看,ruby& rake安装在不同的bin目录中,这就是问题所在。” - 在我的情况下这是真的,但解决方案是什么?如何在正确的位置重新安装rake? &安培;这会解决我的问题吗?

$ which ruby
/usr/local/bin/ruby

$ which rake
/usr/bin/rake

$ rake db:migrate --trace
(in /Users/jessephillips/src/rails_projects/demo_app)
rake aborted!
Could not find RubyGem bundler (>= 0)
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:827:in `report_activate_error'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:261:in `activate'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:68:in `gem'
/Users/jessephillips/src/rails_projects/demo_app/config/boot.rb:2
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
/Users/jessephillips/src/rails_projects/demo_app/config/application.rb:1
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
/Users/jessephillips/src/rails_projects/demo_app/Rakefile:4
/Users/jessephillips/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `load'
/Users/jessephillips/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `raw_load_rakefile'
/Users/jessephillips/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2017:in `load_rakefile'
/Users/jessephillips/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/jessephillips/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2016:in `load_rakefile'
/Users/jessephillips/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2000:in `run'
/Users/jessephillips/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/jessephillips/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Users/jessephillips/.gem/ruby/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19

3 个答案:

答案 0 :(得分:4)

您是否安装了bundler

gem install bundler

然后运行bundle

bundle install

安装所有依赖项

答案 1 :(得分:2)

怎么样:

gem install bundler
bundle

然后重试。

答案 2 :(得分:0)

这不是rake的问题。这意味着您必须安装bundler。 Bundler是一个包含所有项目gem依赖项的gem(想想它是maven,或者如果你来自java背景,那就是ant)

从此处获取更多信息(http://gembundler.com/)

首先需要安装bundler才能运行项目。这是一个很好的入门资源

http://railscasts.com/episodes/201-bundler

希望这会有所帮助

欢呼声

sameera