我对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
我不知道我做错了什么,而且我对此很陌生,以至于我不知道如果我一生都在努力,我可以调试它 - 任何想法/指导?
所有帮助都表示赞赏,并提前致谢!
答案 0 :(得分:2)
Bundler是Ruby应用程序的新依赖项管理系统,用于新的Rails项目。
# ask rubygems to install bundler
$ gem install bundler
# ask bundler to install your app's dependencies
$ bundle install
# run your app & tasks using bundler
$ bundle exec rake db:create
答案 1 :(得分:2)
如果这是您的第一次体验,我建议您从Rails 2.3.8开始。有很多教程和更广泛的支持; 3.0是相当新鲜的几个主要变化。无论如何,你最终都能从2.3.8升级到3.0.0。
答案 2 :(得分:0)
我有同样的错误:
rake aborted!
uninitialized constant Bundler
事实证明它正在发生,因为运行cron任务的环境没有像你的env在shell中那样设置。 .profile和.bash_profile不会在cron任务之前运行。我通过将crontab中的PATH变量设置为部署用户的内容来修复此问题:
PATH=/opt/nginx/sbin:/usr/local/mysql/bin:/opt/local/bin:/opt/local/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/Applications/sshfs/bin
您可以通过运行
来检查这是否是导致您出现问题的原因which ruby
从shell内部和cron任务内部。如果得到不同的结果,它会告诉你cron任务没有运行与shell中相同的ruby,并且运行cron任务的ruby没有安装Bundler gem。