Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Couldn't decrypt config/credentials.yml.enc. Perhaps you passed the wrong key?

I recently deleted my local project but did a git clone and picked up from where I last committed. As I tried to upload images to AWS, which was already configured, I got this error:

Aws::Sigv4::Errors::MissingCredentialsError in RentalsController#create


Cannot load `Rails.config.active_storage.service`: missing credentials, provide credentials with one of the following options: - :access_key_id and :secret_access_key - :credentials - :credentials_provider

I tried to look at my credentials.yml file for any error but when I input this command:

EDITOR="code --wait" rails credentials:edit

...I get this error:

Couldn't decrypt config/credentials.yml.enc. Perhaps you passed the wrong key?

What could be the problem?

like image 337
Brian Ngeywo Avatar asked Aug 10 '20 21:08

Brian Ngeywo


1 Answers

You are missing the master.key

When you create a new project, rails will setup the credentials.yml.enc and a matching master.key file to access the credentials. The master.key file will also automatically be added to the gitignore, so 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.

like image 115
Hackman Avatar answered Nov 20 '22 11:11

Hackman