YAMLで構文エラー

実現したいこと

YAMLで構文エラーが発生しているので改善したいです。

前提

Railsのapp/config/database.yml
Docker イメージ内での作業

発生している問題・エラーメッセージ

YAML syntax error occurred while parsing /app/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 17 column 3

該当のソースコード

YAML

1---2default:3 adapter: sqlite3 4 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>5 timeout: 50006development:7 adapter: sqlite3 8 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>9 timeout: 500010 database: storage/development.sqlite3 11test:12 adapter: sqlite3 13 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>14 timeout: 500015 database: storage/test.sqlite3 16production:17 adapter: mysql2 18 encoding: utf8mb4 19 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>20 host: "<%= ENV['DB_HOST'] %>"21 socket: /var/lib/mysql/mysql.sock 22 database: cat-img-api_production 23 username: <%= ENV['DB_USERNAME'] %>24 password: <%= ENV['DB_PASSWORD'] %>

試したこと

adapter: "mysql2"
encoding: "utf8mb4"リスト

一旦JSONにしてYAMLに変換

--- default: adapter: "sqlite3" pool: "<%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>" timeout: "5000" development: adapter: "sqlite3" pool: "<%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>" timeout: "5000" database: "storage/development.sqlite3" test: adapter: "sqlite3" pool: "<%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>" timeout: "5000" database: "storage/test.sqlite3" production: username: "<%= ENV['DB_USERNAME'] %>" socket: "/var/lib/mysql/mysql.sock" database: "cat-img-api_production" adapter: "mysql2" encoding: "utf8mb4" host: "<%= ENV['DB_HOST'] %>" password: "<%= ENV['DB_PASSWORD'] %>" pool: "<%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>"

結果
YAML syntax error occurred while parsing /app/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 17 column 3

production: adapter: mysql2 encoding: utf8mb4 pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> host: "<%= ENV['DB_HOST'] %>" socket: /var/lib/mysql/mysql.sock database: cat-img-api_production username: <%= ENV['DB_USERNAME'] %> password: <%= ENV['DB_PASSWORD'] %>

だけにしました。 viで検索しましたが空白とかタブはありませんでした。 adapter: mysql2でやはりエラーが出ます。
YAML syntax error occurred while parsing /app/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 2 column 3

コメントを投稿

0 コメント