43

我已经在笔记本电脑上运行 Ruby on Rails 大约一个月了,但是当我想在这个实例中运行服务器时(几个小时前它运行良好),我现在收到了这条消息。请问如何让服务器重新运行?

C:\Sites\LaunchPage>rails s
    C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/psych.rb:203:in `parse': (<unknown>):
    found character that cannot start any token while scanning for the next token at line 17 column 17 (Psych::SyntaxError)
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/psych.rb:203:in `parse_stream'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/psych.rb:151:in `parse'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/psych.rb:127:in `load'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/figaro-0.6.3/lib/figaro.rb:21:in `raw'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/figaro-0.6.3/lib/figaro.rb:17:in `env'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/figaro-0.6.3/lib/figaro/railtie.rb:7:in `block in <class:Railtie>'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:34:in `call'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:34:in `execute_hook'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:42:in `each'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/application.rb:67:in `inherited'
    from C:/Sites/LaunchPage/config/application.rb:13:in `<module:LaunchPage>'
    from C:/Sites/LaunchPage/config/application.rb:12:in `<top (required)>'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:53:in `require'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:53:in `block in <top (required)>'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:50:in `tap'
    from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.8/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'
4

7 回答 7

113

YAML 不接受 TAB 字符 ( \t) 用于缩进。寻找你的那些config/application.yml并用 2 个空格替换。

或者可能有其他语法错误,正如 Ryan 所建议的那样。但我打赌这个

于 2013-10-14T09:39:44.417 回答
25

此错误源自Figaro gem,它向我表明您可能在config/application.yml. 仔细检查此文件是否有任何不正确的 YAML 语法。

于 2013-10-14T09:28:09.780 回答
14

可能不是您的具体示例,但 Stack Overflow 的标题导致我出现在这篇文章中,因此对于那些处理此错误的人来说,这可能是由于:

en.yml 或翻译 yml 或任何 yaml...

字符串插值周围没有双引号

points:
  other: %{points} points

更正:

points:
  other: "%{points} points"
于 2017-04-30T04:01:44.510 回答
8

我和你有同样的问题。我确定它的 TAB 字符 (\t) 问题。请替换为 2 个空格。

于 2014-03-17T08:27:57.237 回答
3

您应该检查所有包含 YAML 的重要配置文件。我在尝试时遇到了同样的错误rake db:seed,结果发现我在config/database.yml.

如果不确定,请使用一些在线 YAML 解析器,即http://yaml-online-parser.appspot.com/

于 2014-03-20T09:37:47.087 回答
2

当 yaml 文件之一出现语法错误“ yaml 中没有选项卡”、yaml 文件可能database.yaml等时,会发生此错误application.yaml

于 2014-11-28T03:36:13.543 回答
-2

[ 文本编辑器截图]

开发:DEV_DB_PASSWORD:'qaz' 分期:STAG_DB_PASSWORD:'qaz'

下一行不应该有任何空格

于 2018-10-23T10:30:31.267 回答