简体   繁体   English

Rails 3 - '无法解析 Yaml'

[英]Rails 3 - 'Couldn't parse Yaml'

I don't know what I did wrong.我不知道我做错了什么。 I try to run 'rails c,' but it just gives me an error.我尝试运行“rails c”,但它只是给了我一个错误。 It was working 10 minutes ago.它在 10 分钟前工作。 :\ :\

C:/Ruby192/lib/ruby/1.9.1/psych.rb:148:in `parse': couldn't parse YAML at line 2
 column 12 (Psych::SyntaxError)
        from C:/Ruby192/lib/ruby/1.9.1/psych.rb:148:in `parse_stream'
        from C:/Ruby192/lib/ruby/1.9.1/psych.rb:119:in `parse'
        from C:/Ruby192/lib/ruby/1.9.1/psych.rb:106:in `load'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/applic
ation/configuration.rb:88:in `database_configuration'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.7/lib/active_r
ecord/railtie.rb:58:in `block (2 levels) in <class:Railtie>'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_
support/lazy_load_hooks.rb:36:in `instance_eval'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_
support/lazy_load_hooks.rb:36:in `execute_hook'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_
support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_
support/lazy_load_hooks.rb:42:in `each'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activesupport-3.0.7/lib/active_
support/lazy_load_hooks.rb:42:in `run_load_hooks'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.7/lib/active_r
ecord/base.rb:1904:in `<top (required)>'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/activerecord-3.0.7/lib/active_r
ecord/railtie.rb:32:in `block in <class:Railtie>'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/railti
e.rb:180:in `call'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/railti
e.rb:180:in `each'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/railti
e.rb:180:in `load_console'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/applic
ation.rb:154:in `block in load_console'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/applic
ation/railties.rb:11:in `each'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/applic
ation/railties.rb:11:in `all'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/applic
ation.rb:154:in `load_console'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/comman
ds/console.rb:26:in `start'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/comman
ds/console.rb:8:in `start'
        from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/comman
ds.rb:23:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

Try adding this at the beginning of config/boot.rb尝试在 config/boot.rb 的开头添加它

require 'yaml'
YAML::ENGINE.yamler= 'syck'

Just for the record, YAML doesn't accept tabs as indentation, they must be spaces.仅作记录, YAML 不接受制表符作为缩进,它们必须是空格。 Changing tabs to spaces solved it for me ^^将制表符更改为空格为我解决了这个问题^^

The stack dump mentions database_configuration, so I'd start with your database.yml file.堆栈转储提到了 database_configuration,所以我将从您的 database.yml 文件开始。

    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application/configuration.rb:88:in `database_configuration'

"Couldn't parse Yaml" Go to your project and see near the project name there is a. "Couldn't parse Yaml" Go 到你的项目,看看项目名称附近有一个。 sign.open it and see in which file conflict occurred,right click that file.select Replace with then Latest from Repository.Do this for all the files u changed code.then run the server it will work.签名。打开它并查看发生在哪个文件冲突,右键单击该文件。select 替换为来自存储库的最新版本。对您更改代码的所有文件执行此操作。然后运行服务器它将工作。

I issued this problem with an unquoted * in one of my YAML file.我在我的 YAML 文件之一中用未引用的 * 发出了这个问题。

fr:
  simple_form:
    yes: Oui
    no:  Non

    required:
      text: required
      mark: "*"

Hope it will help.希望它会有所帮助。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM