Rails 3 - “无法解析 Yaml”

发布于 2024-11-04 19:02:10 字数 2780 浏览 0 评论 0原文

我不知道我做错了什么。我尝试运行“rails c”,但它只是给了我一个错误。 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>'

I don't know what I did wrong. I try to run 'rails c,' but it just gives me an error. It was working 10 minutes ago. :\

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>'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

执笔绘流年 2024-11-11 19:02:10

尝试将其添加到 config/boot.rb 的开头

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

Try adding this at the beginning of config/boot.rb

require 'yaml'
YAML::ENGINE.yamler= 'syck'
椒妓 2024-11-11 19:02:10

郑重声明一下,YAML 不接受制表符作为缩进,它们必须是空格。将制表符更改为空格解决了我的问题 ^^

Just for the record, YAML doesn't accept tabs as indentation, they must be spaces. Changing tabs to spaces solved it for me ^^

忆依然 2024-11-11 19:02:10

堆栈转储提到了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'

The stack dump mentions database_configuration, so I'd start with your database.yml file.

    from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.7/lib/rails/application/configuration.rb:88:in `database_configuration'
妳是的陽光 2024-11-11 19:02:10

“无法解析 Yaml”
转到您的项目并查看项目名称附近有一个!签名。打开它并查看哪个文件发生冲突。右键单击该文件,选择替换为,然后选择存储库中的最新版本。对您更改代码的所有文件执行此操作。然后运行它将起作用的服务器。

"Couldn't parse Yaml"
Go to your project and see near the project name there is a ! 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.

迷路的信 2024-11-11 19:02:10

我在我的 YAML 文件之一中使用不带引号的 * 来发出此问题。

fr:
  simple_form:
    yes: Oui
    no:  Non

    required:
      text: required
      mark: "*"

希望它会有所帮助。 :)

I issued this problem with an unquoted * in one of my YAML file.

fr:
  simple_form:
    yes: Oui
    no:  Non

    required:
      text: required
      mark: "*"

Hope it will help. :)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文