2012-05-04 51 views
10

我在運行在fedora 16 Rails 2.3.5和Ruby 1.9.2.p320上的Rails應用程序中遇到問題。該應用程序在Ubuntu 11.10上運行良好。當我運行rails服務器並打開任何控制器時出現以下錯誤。Psych :: SyntaxError無法解析YAML

精極度緊張:: SyntaxError錯誤在controllername#actionname

無法解析YAML

我曾嘗試採用下面的技巧,但它不是爲我工作。

我已經添加在配置以下行/的boot.rb

require 'yaml' 

YAML::ENGINE.yamler = 'syck' 

的錯誤跟蹤

.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/psych.rb:148:in `parse' 
.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/psych.rb:148:in `parse_stream' 
.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/psych.rb:119:in `parse' 
.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/psych.rb:106:in `load' 
.rvm/gems/[email protected]/gems/activesupport-2.3.5/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb:189:in `load_yml' 
.rvm/gems/[email protected]/gems/activesupport-2.3.5/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb:176:in `load_file' 
.rvm/gems/[email protected]/gems/activesupport-.3.5/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb:13:in `block in load_translations' 
.rvm/gems/[email protected]/gems/activesupport-2.3.5/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb:13:in `each' 
.rvm/gems/[email protected]/gems/activesupport-2.3.5/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb:13:in `load_translations' 
.rvm/gems/[email protected]/gems/activesupport-2.3.5/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb:85:in `init_translations' 
.rvm/gems/[email protected]/gems/activesupport-2.3.5/lib/active_support/vendor/i18n-0.1.3/lib/i18n/backend/simple.rb:74:in `available_locales' 
.rvm/gems/[email protected]/gems/activesupport-2.3.5/lib/active_support/vendor/i18n-0.1.3/lib/i18n.rb:50:in `available_locales' 
.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_view/template.rb:226:in `valid_locale?' 
.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_view/template.rb:243:in `parse_extensions' 
.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_view/template.rb:233:in `split' 
.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_view/template.rb:118:in `initialize' 
.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_view/reloadable_template.rb:81:in `initialize' 
.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_view/reloadable_template.rb:38:in `new' 
.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_view/reloadable_template.rb:38:in `register_template_from_file' 
.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_view/reloadable_template.rb:62:in `block in load_all_templates_from_dir' 
.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_view/reloadable_template.rb:62:in `each' 
.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_view/reloadable_template.rb:62:in `load_all_templates_from_dir' 
.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_view/reloadable_template.rb:29:in `[]' 
.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_view/paths.rb:48:in `block in find_template' 
.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_view/paths.rb:47:in `each' 
.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_view/paths.rb:47:in `find_template' 
.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_controller/base.rb:1389:in `default_template' 
.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_controller/base.rb:905:in `render' 
.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:51:in `block in render_with_benchmark' 
.rvm/gems/[email protected]/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `block in ms' 
.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/benchmark.rb:310:in `realtime' 
.rvm/gems/[email protected]/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `ms' 
.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:51:in `render_with_benchmark' 
.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_controller/base.rb:1326:in `default_render' 
.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_controller/base.rb:1332:in `perform_action' 
.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_controller/filters.rb:617:in `call_filters' 
.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_controller/filters.rb:610:in `perform_action_with_filters' 
/.rvm/gems/[email protected]/gems/actionpack-2.3.5/lib/action_controller/benchmarking.rb:68:in `block in perform_action_with_benchmark' 
.rvm/gems/[email protected]/gems/activesupport-2.3.5/lib/active_support/core_ext/benchmark.rb:17:in `block in ms' 
.rvm/rubies/ruby-1.9.2-p320/lib/ruby/1.9.1/benchmark.rb:310:in `realtime 

回答

7

舊YAML解析器不喜歡有標籤,但只有空格。您可能需要檢查YAML文件以查看它是否在第18行有任何選項卡。如果是這種情況,您可能需要修復YAML文件或升級解析器。

+2

我已經添加下面的行environment.rb文件中 需要 'YAML' YAML :: ENGINE.yamler = 'SYCK' –

+0

感謝 - 你化險爲夷。 – johndpope

+0

這是正確的解決方案。確保在單獨一行中包含「YAML :: ENGINE.yamler ='syck'」。 –