Rails 4.2 MySQL 5.6 Elastic Beanstalk YAML 语法错误

Posted

技术标签:

【中文标题】Rails 4.2 MySQL 5.6 Elastic Beanstalk YAML 语法错误【英文标题】:Rails 4.2 MySQL 5.6 Elastic Beanstalk YAML Syntax Error 【发布时间】:2015-06-01 13:31:01 【问题描述】:

所以我正在尝试将 ruby​​ on rails 应用程序部署到 Amazon AWS Elastic Beanstalk。终端中没有错误,但应用程序不会部署。当我检查日志时,显示了两个错误

Activity execution failed, because: command failed with error code 1: /opt/elasticbeanstalk/hooks/appdeploy/pre/12_db_migration.sh

在这之下……

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>): did not find expected key while parsing a block mapping at line 21 column 3

Psych::SyntaxError: (<unknown>): did not find expected key while parsing a block mapping at line 21 column 3

Tasks: TOP => db:migrate => db:load_config

我一遍又一遍地检查了我的 database.yml 文件是否有错误,但在这里没有看到任何内容

development:
  adapter: mysql2
  encoding: utf8
  pool: 5
  username: sean
  password: "mypass"
  socket: /var/run/mysqld/mysqld.sock
  database: reviewchipWebsite_development

test:
  adapter: mysql2
  encoding: utf8
  pool: 5
  username: sean
  password: "mypass"
  socket: /var/run/mysqld/mysqld.sock
  database: reviewchipWebsite_test

production:
  adapter: mysql2
  encoding: utf8
  database: ebdb
  username: seanAndrew
  password: "mypass"
  host: aa1bszpu5vavup2.cvln1rz36k57.us-west-2.rds.amazonaws.com
  port: 3306
  socket: /var/lib/mysql/mysql.sock

【问题讨论】:

YAML 非常挑剔,你可能会有一些非打印字符(比如额外的换行符)。尝试在yamllint.com 复制粘贴您的 database.yml,它会清理它。 感谢修复 太棒了!如果您不介意,我会将我的评论作为答案:) 【参考方案1】:

YAML 非常挑剔,你可能会有一些非打印字符(比如额外的换行符)。尝试在yamllint.com 复制粘贴您的 database.yml,它会清理它。

【讨论】:

以上是关于Rails 4.2 MySQL 5.6 Elastic Beanstalk YAML 语法错误的主要内容,如果未能解决你的问题,请参考以下文章

如何在带有 Rails 4.2 的专用调试端口上使用工头启动 Rails?

Arel + Rails 4.2 导致问题(绑定丢失)

ruby 2.5 是不是已经用 Rails 4.2 测试过?

Rails 4.2 不创建非消化资产

Docker - Rails Development Auto Reload Broken (Rails 4.2) Mac NFS

rails 4.2 DataTables无法重新初始化DataTable