【问题标题】:YAML Parsing Issue in RailsRails 中的 YAML 解析问题
【发布时间】:2023-03-31 16:23:02
【问题描述】:

我在 Elastic Beanstalk 部署上有一个问题:

YAML syntax error occurred while parsing /var/app/ondeck/config/database.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Error: (<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 1 /var/app/ondeck/config/environment.rb:5:in `<top (required)>' /opt/rubies/ruby-2.4.2/bin/bundle:23:in `load' /opt/rubies/ruby-2.4.2/bin/bundle:23:in `<main>'

Caused by: Psych::SyntaxError: (<unknown>): found character that cannot start any token while scanning for the next token at line 2 column 1 /var/app/ondeck/config/environment.rb:5:in `<top (required)>' /opt/rubies/ruby-2.4.2/bin/bundle:23:in `load' /opt/rubies/ruby-2.4.2/bin/bundle:23:in `<main>' Tasks: TOP => environment (See full trace by running task with --trace).

正如我所读到的,这是因为 YAML 禁止使用制表符,而是使用空格。

问题是我手动检查了每个 YAML 文件的选项卡,但从未找到。我想我错过了一些东西所以我的问题是:是否有任何脚本可以遍历我的整个源代码,在每个 YAML 文件中用 2 个空格替换制表符?

【问题讨论】:

  • 您不需要检查每个文件。仅检查“/var/app/ondeck/config/database.yml”。
  • 我做了,但一直没解决

标签: ruby-on-rails ruby yaml amazon-elastic-beanstalk


【解决方案1】:

毕竟它是 ruby​​:编写脚本比在 SO 和谷歌上提问更容易、更快捷。

Dir['*/**/*.yml'].each do |f| 
  File.write(f, File.read(f).gsub(/\t/, '  '))
end

【讨论】:

  • 你自己写一个脚本是对的:)
猜你喜欢
  • 2018-06-04
  • 2012-02-27
  • 1970-01-01
  • 1970-01-01
  • 2011-08-16
  • 1970-01-01
  • 2016-01-15
  • 1970-01-01
  • 2011-06-26
相关资源
最近更新 更多