Ruby-on-rails 我收到“在扫描下一个令牌时发现无法启动任何令牌的字符”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19356278/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
I'm getting "found character that cannot start any token while scanning for the next token"
提问by asaignment
I have been running Ruby on Rails on my laptop for about a month now, but when I wanted to run the server in this instance (and it was working fine a few hours ago) I now receive this message. How can I get the server to run again please?
我已经在我的笔记本电脑上运行 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>'
采纳答案by Ryan Bigg
This error is originating from the Figaro gem, which would indicate to me that you probably have a syntax error in config/application.yml. Double check this file for any incorrect YAML syntax.
此错误源自Figaro gem,它向我表明您可能在config/application.yml. 仔细检查此文件是否有任何不正确的 YAML 语法。
回答by Sergio Tulentsev
YAML does not accept TAB characters (\t) for indentation. Look for those in your config/application.ymland replace with 2 spaces.
YAML 不接受\t用于缩进的制表符 ( )。查找您中的那些config/application.yml并替换为 2 个空格。
(or there may be other syntax errors, as suggested by Ryan. But I'm betting on this one)
(或者可能有其他语法错误,正如 Ryan 所建议的那样。但我打赌这个)
回答by Alex Grande
May not be your specific example, but the title of the Stack Overflow resulted in me being on this post so for those working with this error, it may be due to:
可能不是你的具体例子,但 Stack Overflow 的标题导致我出现在这篇文章中,所以对于那些处理这个错误的人来说,可能是由于:
en.yml or a translation yml or any yaml...
en.yml 或翻译 yml 或任何 yaml...
That doesn't have double quotes around a string interpolation
字符串插值周围没有双引号
points:
other: %{points} points
Correction:
更正:
points:
other: "%{points} points"
回答by BruceYue
I have the same issue with yours. I'm sure its the TAB characters (\t) issue. Please replace with 2 spaces.
我和你有同样的问题。我确定它的制表符 (\t) 问题。请替换为 2 个空格。
回答by sampi
You should check all important configuration files that contains YAML. I had the same error when tried to rake db:seed, and it turns out that I had TAB character in commented block in config/database.yml.
您应该检查所有包含 YAML 的重要配置文件。我在尝试时遇到了同样的错误rake db:seed,结果是我在config/database.yml.
If you are not sure, use some online YAML parser, i.e. http://yaml-online-parser.appspot.com/.
如果您不确定,请使用一些在线 YAML 解析器,即http://yaml-online-parser.appspot.com/。
回答by Shonhloi
This error occurs when one of yaml files get syntax error "no tab in yaml", yaml files maybe database.yaml, application.yamletc.
当YAML文件一赠语法错误“出现此错误在YAML无标签”,YAML文件也许database.yaml,application.yaml等
回答by ratan
[
]
[
]
development: DEV_DB_PASSWORD: 'qaz' staging: STAG_DB_PASSWORD: 'qaz'
开发:DEV_DB_PASSWORD:'qaz' 分期:STAG_DB_PASSWORD:'qaz'
there should not be any space in every next line
每下一行都不应该有任何空格

