Rails not able to decrypt credentials with master.key


This Content is from Stack Overflow. Question asked by user3738936

I just generated a new config/master.key by running
EDITOR="code --wait" bin/rails credentials:edit yesterday.

Today I started trying to run other commands like, a basic example bundle exec rails and I am getting this.

message_encryptor.rb:206:in `rescue in _decrypt': ActiveSupport::MessageEncryptor::InvalidMessage (ActiveSupport::MessageEncryptor::InvalidMessage)


/activesupport-5.2.4/lib/active_support/message_encryptor.rb:201:in `final': OpenSSL::Cipher::CipherError

These were the errors that prompted me to run EDITOR="code --wait" bin/rails credentials:edit to begin with, but now I have the config/master.key.

I’ve also added RAILS_MASTER_KEY=*** to my .env (as a troubleshooting step). That hasn’t helped.

When I attempt to decrypt it with EDITOR="code --wait" bin/rails credentials:edit, I get the same error.

Not sure what the issue could be since I have the key, I just made it and I am not doing operations that actually involve decrypting & I am still getting the same error. It feels like a broken process.


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?