LoginSignup
0
0

More than 5 years have passed since last update.

gem squasher 実行時にdatabase.yml内に環境変数ENVでDBユーザ名/パスワードを読み込んでいるとエラーになる

Last updated at Posted at 2018-12-10

squasher を実行しようとしたらDB接続のエラーが出てしまう。

$ bundle exec squasher 2019 -m 5.0
Squasher is creating a tmp database
Access denied for user 'root'@'localhost' (using password: NO)
Couldn't drop database 'squasher'
rake aborted!
Mysql2::Error: Access denied for user 'root'@'localhost' (using password: NO)
・
・
・
(以下略)

どうやらdotenvなど含めて、環境変数をdatabase.yml内で使ってると、squasherがそれを読み込めていないよう。
一旦、パスワードを直接書き込めば実行しましたが、issueも上がってたので、PRチャンスってやつですね。
https://github.com/jalkoby/squasher/issues/30

具体的にはこういうやつです。

# database.yml
development: &default
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: <%= ENV['DB_NAME'] %>
  pool: 5
  username: <%= ENV['DB_USER'] %>
  password: <%= ENV['DB_PASSWORD'] %>

ちなみに実行時のファイルを眺めてたら、実行中だけdatabase.ymlの中身書き換えて、tmpデータベース接続してるんですね。(なかなか豪快。

# database.yml
---
development:
  adapter: mysql2
  encoding: utf8
  reconnect: false
  database: squasher
  pool: 5
  username: ****
  password: ****

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0