我收到“在扫描下一个令牌时找不到任何令牌的字符”
我已经在我的笔记本电脑上运行Ruby on Rails大约一个月了,但是当我想在这个实例中运行服务器时(几小时前工作正常)我现在收到此消息。 我怎样才能让服务器再次运行?
C:\Sites\LaunchPage>rails s C:/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/psych.rb:203:in `parse': (): 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 ' 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 `' from C:/Sites/LaunchPage/config/application.rb:12:in `' 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 ' 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 `' from script/rails:6:in `require' from script/rails:6:in `'
此错误源自Figaro gem ,它会向我表明您在config/application.yml
可能存在语法错误。 仔细检查此文件是否有任何不正确的YAML语法。
YAML不接受缩进的TAB字符( \t
)。 在config/application.yml
查找那些并替换为2个空格。
( 或者可能存在其他语法错误,如Ryan所建议的那样。但我打赌这个错误 )
我和你的问题一样。 我确定它的TAB字符(\ t)问题。 请更换2个空格。
可能不是您的具体示例,但Stack Overflow的标题导致我出现在此post中,因此对于使用此错误的人来说,可能是由于:
en.yml或翻译yml或任何yaml …
字符串插值周围没有双引号
points: other: %{points} points
更正:
points: other: "%{points} points"
您应该检查包含YAML的所有重要配置文件。 尝试rake db:seed
时我遇到了同样的错误,结果发现我在config/database.yml
中的注释块中有TAB字符。
如果您不确定,请使用一些在线YAML解析器,即http://yaml-online-parser.appspot.com/ 。
当其中一个yaml文件出现语法错误“ yaml中没有选项卡 ”时,会发生此错误,yaml文件可能是database.yaml
, application.yaml
等。
[ ]
开发:DEV_DB_PASSWORD:’qaz’staging:STAG_DB_PASSWORD:’qaz’
每一行都不应该有任何空间