2010-09-06 63 views
3

我對Rails很陌生,所以請原諒我的理解不夠。我已經安裝了RubyGems和Ruby,Rails的,耙,並通過了RubyGems的MySQL等的最新版本,但開始做一個基本的Rails應用程序時,我有這樣的問題:Ruby與Rake的軌道問題

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 

我不知道我做了什麼錯了,而且我對這件事很陌生,以至於我不知道如果我花了整整一生的時間對它進行調試,我是否可以進行調試 - 任何想法/指導?

所有幫助表示感謝,並提前致謝!

回答

2

我建議從Rails 2.3.8開始,如果這是您的第一次體驗。有很多教程和更廣泛的支持; 3.0是相當新鮮的幾個重大變化。無論如何,你將能夠從2.3.8升級到3.0.0。

+0

然後我會怎麼去降級呢? – 2010-09-07 03:13:45

+0

看來,我已安裝軌道2.3.8以及3.0.0?當我運行'gem list'時,我得到'rails(3.0.0,2.3.8)'作爲其中一行。這是否意味着我可以選擇要激活哪個版本的導軌? – 2010-09-07 03:45:56

+0

'rails _2.3.8_ people' – BenB 2010-09-07 06:46:25

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 
+0

我試過了,得到如下輸出:http://pastebin.com/9qxBdFVP – 2010-09-07 00:32:21

+0

也粘貼'Gemfile'的內容。 – yfeldblum 2010-09-07 00:50:05

+0

Gemfile:http://pastebin.com/jGYG37yR – 2010-09-07 00:58:58

0

我有同樣的錯誤:

rake aborted! 
uninitialized constant Bundler 

事實證明,它發生是因爲運行的cron任務環境設置不喜歡你的ENV是一個殼體內。 .profile和.bash_profile在cron任務之前不運行。

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 

造成您的問題:我在crontab中的PATH變量設置爲它是什麼部署用戶解決了這個從一個cron任務中。如果你得到不同的結果,它會告訴你cron任務沒有像你在shell中那樣運行相同的ruby,並且運行cron任務的ruby沒有安裝Bundler gem。