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

发布于 2024-10-31 11:40:16 字数 2403 浏览 4 评论 0原文

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

$ rake db:migrate

我收到此错误:

Rake Aborted!
Uninitialized constant Bundler

Looking around here &谷歌搜索,我不知道该怎么办。类似问题的“答案”之一是:“哦,看,ruby 和 rake 安装在不同的 bin 目录中,这就是问题所在。” - 我的情况确实如此,但是解决方案是什么?如何将耙子重新安装到正确的位置? &这能解决我的问题吗?

$ 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

I'm a totall new Ruby & Rails programmer.
When I try to run rake for the first time:

$ rake db:migrate

I get this error:

Rake Aborted!
Uninitialized constant Bundler

Looking around here & googling, I don't know what to do. One of the "answers" to a similar question was: "oh, look, ruby & rake are installed in different bin directories, that's the problem." - that's true in my case, but what is the solution? How do I reinstall rake in the right place? & will that fix my issue?

$ 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

苍暮颜 2024-11-07 11:40:16

您是否安装了bundler

gem install bundler

然后运行 ​​bundle

bundle install

安装所有依赖项

Do you have bundler installed?

gem install bundler

And then run bundle or

bundle install

to install all your dependencies

天气好吗我好吗 2024-11-07 11:40:16

怎么样:

gem install bundler
bundle

然后重试。

what about:

gem install bundler
bundle

then retry.

半暖夏伤 2024-11-07 11:40:16

这不是耙子的问题。这意味着您必须安装捆绑程序。 Bundler 是一个 gem,它打包了所有项目 gem 依赖项(如果您来自 java 背景,可以将其视为 maven,或者 ant)

从这里获取更多信息(http://gembundler.com/),

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

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

希望这有助于

欢呼

为Sameera

This is not a problem with rake. This means you have to install bundler. Bundler is a gem which package all your project gem dependencies (Think of it as maven, or ant if you are coming from java background)

get more information from here (http://gembundler.com/)

you first need to install bundler to run your project. here is a good resource to get started

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

hope this helps

cheers

sameera

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文