LoginSignup
1
0

More than 3 years have passed since last update.

[Rails] ActiveSupport::MessageEncryptor::InvalidMessageの解決方法

Last updated at Posted at 2021-02-10

なぜこのエラー?

credentialとmaster.keyの整合性が取れていない。
[Rails] credentials.yml.enc、master.keyについて。

「端的にcredentials.yml.encの文字列とmaster.keyの文字列の組み合わせが不正解であるということです。」

他にも

if you delete your project local and clone it again your master.key will be lost.

The only way to fix this is by setting up new credentials.yml.enc and add your AWS credentials to it again.
First you need to remove the existing credentials.yml.enc and then run: rails credentials:edit to create a new one.

つまり、master.keyがなんらかの理由で(gitからclone, docker再ビルドetc)変わった、無くなった。

credential.yml.encと整合性が取れない。

解決方法

credential.yml.encファイルの消して、

rm credentials.yml.enc
EDITOR=vim bin/rails credentials:edit

でmaster.keyを再び作る


こういう書き方でも出来ました

# rm credentials.yml.enc
# rails credentials:edit
No $EDITOR to open file in. Assign one like this:

EDITOR="mate --wait" bin/rails credentials:edit

For editors that fork and exit immediately, it's important to pass a wait flag,
otherwise the credentials will be saved immediately with no chance to edit.
# EDITOR="mate --wait" bin/rails credentials:edit
Adding config/master.key to store the encryption key:*******************

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

File encrypted and saved.

1
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
1
0