我收到"在扫描下一个令牌时找不到任何令牌的字符"

asa*_*ent 29 ruby ruby-on-rails ruby-on-rails-3

我已经在我的笔记本电脑上运行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>'
Run Code Online (Sandbox Code Playgroud)

Ser*_*sev 78

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

(或者可能存在其他语法错误,如Ryan所建议的那样.但我打赌这个错误)

  • 对我来说就是这样.从赞成票来看,我不是第一个. (3认同)

Rya*_*igg 18

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

  • 我的发短信有混淆标签和空格的倾向.我确保我的application.yaml文件没有包含任何标签(替换为空格)为我修复了问题. (10认同)

Ale*_*nde 7

可能不是您的特定示例,但是Stack Overflow的标题导致我出现在此职位上,因此对于那些使用此错误的人,原因可能是:

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

字符串内插没有双引号

points:
  other: %{points} points
Run Code Online (Sandbox Code Playgroud)

更正:

points:
  other: "%{points} points"
Run Code Online (Sandbox Code Playgroud)


小智 6

我和你的问题一样.我确定它的TAB字符(\ t)问题.请更换2个空格.