Ruby on Rails 与 Rake 的问题
我对 Rails 还很陌生,所以请原谅我的缺乏理解。我已经通过 RubyGems 安装了最新版本的 RubyGems、Ruby、Rails、Rake 和 MySQL 等,但是在开始制作基本的 Rails 应用程序时遇到了这个问题:
Icarus:temporary atg$ rails new people
... (output omitted) ...
Icarus:temporary atg$ cd people
Icarus:people atg$ rake db:create
(in /Users/atg/temporary/people)
rake aborted!
uninitialized constant Bundler
/Users/atg/temporary/people/Rakefile:4
(See full trace by running task with --trace)
Icarus:people atg$ rake db:create --trace
(in /Users/atg/temporary/people)
rake aborted!
uninitialized constant Bundler
/Users/atg/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2503:in `const_missing'
/Users/atg/temporary/people/config/boot.rb:9
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Users/atg/temporary/people/config/application.rb:1
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Users/atg/temporary/people/Rakefile:4
/Users/atg/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `load'
/Users/atg/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `raw_load_rakefile'
/Users/atg/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2017:in `load_rakefile'
/Users/atg/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/atg/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2016:in `load_rakefile'
/Users/atg/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2000:in `run'
/Users/atg/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/atg/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Users/atg/.gem/ruby/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
我不知道我做错了什么,我很沮丧对此我不熟悉,如果我花了一生的时间来研究它,我不知道我可以调试它——有什么想法/指导吗?
感谢所有帮助并提前致谢!
I'm very new to Rails, so please forgive my lack of understanding. I've installed the latest versions of RubyGems, Ruby, Rails, Rake, and MySQL etc via RubyGems, but I have this problem when starting to make a basic Rails app:
Icarus:temporary atg$ rails new people
... (output omitted) ...
Icarus:temporary atg$ cd people
Icarus:people atg$ rake db:create
(in /Users/atg/temporary/people)
rake aborted!
uninitialized constant Bundler
/Users/atg/temporary/people/Rakefile:4
(See full trace by running task with --trace)
Icarus:people atg$ rake db:create --trace
(in /Users/atg/temporary/people)
rake aborted!
uninitialized constant Bundler
/Users/atg/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2503:in `const_missing'
/Users/atg/temporary/people/config/boot.rb:9
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Users/atg/temporary/people/config/application.rb:1
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
/Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
/Users/atg/temporary/people/Rakefile:4
/Users/atg/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `load'
/Users/atg/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `raw_load_rakefile'
/Users/atg/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2017:in `load_rakefile'
/Users/atg/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/atg/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2016:in `load_rakefile'
/Users/atg/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2000:in `run'
/Users/atg/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/Users/atg/.gem/ruby/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/Users/atg/.gem/ruby/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
I have no idea what I did wrong, and I'm so new to this that I don't know that I could debug it if I spent my whole life working on it -- any ideas / guidance?
All help is appreciated and thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果这是您的第一次体验,我建议您从 Rails 2.3.8 开始。有很多教程和更广泛的支持; 3.0 相当新鲜,有几个重大变化。无论如何,您最终都可以从 2.3.8 升级到 3.0.0。
I would recommend starting with Rails 2.3.8 if this is your first experience. There are many tutorials and wider support; 3.0 is fairly fresh with several major changes. You'll be able to upgrade from 2.3.8 to 3.0.0 eventually anyway.
Bundler 是 Ruby 应用程序的新依赖项管理系统,用于新的 Rails 项目。
Bundler is the new dependencies management system for Ruby apps, and is used in new Rails projects.
我遇到了同样的错误:
事实证明,这是因为运行 cron 任务的环境没有像您的环境位于 shell 内那样设置。 .profile 和 .bash_profile 不会在 cron 任务之前运行。我通过将 crontab 中的 PATH 变量设置为部署用户的值来修复此问题:
运行来检查这是否是导致问题的原因
您可以通过从 shell 内部和 cron 任务内部 。如果您得到不同的结果,它会告诉您 cron 任务没有运行与 shell 中相同的 ruby,并且 cron 任务正在运行的 ruby 没有安装 Bundler gem。
I had the same error:
It turns out it was happening because the environment running the cron task is not set up like your env is inside a shell. The .profile and .bash_profile are not run before cron tasks. I fixed this by setting the PATH variable in crontab to what it is for the deploy user:
You can check if this is what's causing your issue by running
from inside the shell and from inside a cron task. If you get different results it tells you the cron task is not running the same ruby as you do in the shell and that the ruby the cron task is running does not have the Bundler gem installed.