Rails database.yml エラーYAML syntax error occurred while parsing /project/config/database.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Error: (): found character that cannot start any token while scanning for the next token

Rails database.yml エラーYAML syntax error occurred while parsing /project/config/database.yml. Please note that YAML must be consistently indented using spaces. Tabs are not allowed. Error: (): found character that cannot start any token while scanning for the next token

railsコマンド実行時にめちゃくちゃはまったエラーです。

yamlが読めなかったエラーなんですが、該当箇所を見てみましたが変な文字は入っていませんでした。

YAML syntax error occurred while parsing /project/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 5 column 13

色々とデバッグしていく中で分かった事ですが

原因としてはパスワードの最初に記号があり、yaml上で展開出来なかった為でした。

password: <%= ENV['PGPASSWORD'] %>

↑を↓のように変更したら解消しました。

password: <%= ENV['PGPASSWORD'].to_s.inspect %>

パスワードの先頭文字には記号を使わなければこんな事にならなかったのですが、

というかenvを展開するときなどには気を付けようと思いました。初歩的なミスなのに特定するのにすごい時間がかかってしまいました。

Comments

No comments yet. Why don’t you start the discussion?

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です