ruby 我收到“在扫描下一个令牌时发现无法启动任何令牌的字符”

ozxc1zmp  于 2022-12-12  发布在  Ruby
关注(0)|答案(8)|浏览(146)

我在笔记本电脑上运行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>'
c86crjj0

c86crjj01#

YAML不接受TAB字符(\t)作为缩进。请在config/application.yml中查找这些字符并替换为2个空格。
(* 或者可能有其他语法错误,如Ryan所建议的。但我打赌这一个 *)

3ks5zfa0

3ks5zfa02#

这个错误来自于Figaro gem,这表示您可能在config/application.yml中有语法错误。请仔细检查这个档案是否有任何不正确的YAML语法。

isr3a4wc

isr3a4wc3#

可能不是你的具体例子,但堆栈溢出的标题导致我在这篇文章,所以对于那些工作与此错误,它可能是由于:
一个翻译的yml或任何yaml...
字符串插值前后没有双引号

points:
  other: %{points} points

更正:

points:
  other: "%{points} points"
rsaldnfx

rsaldnfx4#

我也有同样的问题。我肯定是制表符(\t)的问题。请用2个空格替换。

hgqdbh6s

hgqdbh6s5#

你应该检查所有包含YAML的重要配置文件。我在尝试rake db:seed时也遇到了同样的错误,结果发现我在config/database.yml的注解块中有TAB字符。
如果您不确定,请使用一些在线YAML解析器,例如http://yaml-online-parser.appspot.com/

9avjhtql

9avjhtql6#

当其中一个yaml文件获得语法错误“* yaml中没有选项卡 *"时会发生此错误,yaml文件可能是database.yamlapplication.yaml等。

wwtsj6pe

wwtsj6pe7#

当你在yaml中使用未声明的变量时,也会发生这个问题,这会导致缩进问题。在我的例子中,类似于:

props:
    prop1: @app.prop1@
    prop2: @app.prop2@

因此,请确保声明了所有变量。

okxuctiv

okxuctiv8#

[

](第一次)
发展:设备数据库密码:“qaz”分段:STAG数据库密码:'卡兹'
每下一行中不应有任何空格

相关问题