问题描述
我最近删除了我的本地项目,但是做了一个git克隆,然后从我上次提交的地方拿起了。当我尝试将图像上传到已配置的AWS时,出现此错误:
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
我尝试查看我的credentials.yml
文件是否存在任何错误,但是当我输入以下命令时:
EDITOR="code --wait" rails credentials:edit
...我收到此错误:
Couldn't decrypt config/credentials.yml.enc. Perhaps you passed the wrong key?
可能是什么问题?
解决方法
您缺少master.key
创建新项目时,Rails将设置credentials.yml.enc
和匹配的master.key
文件来访问凭据。 master.key
文件也将自动添加到gitignore中,因此,如果您删除项目本地并再次克隆,则master.key
将丢失。
解决此问题的唯一方法是设置新的credentials.yml.enc
并再次向其中添加您的AWS凭证。
首先,您需要删除现有的credentials.yml.enc
,然后运行:
rails credentials:edit
创建一个新的