Rails 3 - “无法解析 Yaml”
我不知道我做错了什么。我尝试运行“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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
尝试将其添加到 config/boot.rb 的开头
Try adding this at the beginning of config/boot.rb
郑重声明一下,YAML 不接受制表符作为缩进,它们必须是空格。将制表符更改为空格解决了我的问题
^^
Just for the record, YAML doesn't accept tabs as indentation, they must be spaces. Changing tabs to spaces solved it for me
^^
堆栈转储提到了database_configuration,因此我将从您的database.yml 文件开始。
The stack dump mentions database_configuration, so I'd start with your database.yml file.
“无法解析 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.
我在我的 YAML 文件之一中使用不带引号的 * 来发出此问题。
希望它会有所帮助。 :)
I issued this problem with an unquoted * in one of my YAML file.
Hope it will help. :)