【Rails on Docker】credentials.yml.encからmaster.keyを取得する時につまずいたのでメモ
Gemインストールしたのにインストールされてないと言われて…
$ EDITOR='code --wait' rails credentials:edit => Could not find minitest-5.12.0 in any of the sources Run `bundle install` to install missing gems.
環境変数EDITORにvscodeを設定してmaster.keyを生成しようとしました。
minitestがインストールされてない?ほんまか、書いたぞと
Gemfile.lockを確認
〜 略 〜 activesupport (5.2.3) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) 〜 略 〜
あるじゃないか!
cacheが利用されてgemがインストールされていない可能性
fuqda.hatenablog.com こちらの著者様が同じような状況にあったので、gemをcacheなしでインストールしてみる。
docker-compose build --no-cache
さて、再チャレンジ。
$ EDITOR='code --wait' rails credentials:edit => Could not find minitest-5.12.0 in any of the sources Run `bundle install` to install missing gems.
やっぱりだめですね。gem list
を確認してもminitestはインストールされているので、やっぱりそれ以外の部分ですね。
docker環境だと特殊でした
qiita.com
こちらの救世主様のおかげで迷宮から抜け出せました。
結局docker環境では以下のようにしないとだめということです。
$ docker-compose run -e EDITOR="code --wait" web rails credentials:edit =>Starting weinance_chrome_1 ... done Starting weinance_db_1 ... done Adding config/master.key to store the master encryption key: 17f778ead1411a7a0dd35a447bf3f12d Save this in a password manager your team can access. If you lose the key, no one, including you, can access anything encrypted with it. create config/master.key ( 以下略 )
無事、master.keyがconfig
直下に作成されました。