Heroku: Couldn't find Active Storage configuration in /app/config/storage.yml (RuntimeError)
I had this same issue when deploying a recently upgraded Rails app. The application was upgraded from Rails 5 to Rails 6. However, when I try deploying to Heroku, I got the error below:
2021-02-12T17:32:33.404828+00:00 app[web.1]: ! Unable to load application: RuntimeError: Couldn't find Active Storage configuration in /app/config/storage.yml2021-02-12T17:32:33.404874+00:00 app[web.1]: bundler: failed to load command: puma (/app/vendor/bundle/ruby/2.7.0/bin/puma)2021-02-12T17:32:33.404958+00:00 app[web.1]: RuntimeError: Couldn't find Active Storage configuration in /app/config/storage.yml
Here's how I fixed it:
I checked the config
directory of my application and realized that it had no config/storage.yml
file. All I had to do was to create the file, and copy the vanilla template that comes with Rails 6 applications into the file:
test: service: Disk root: <%= Rails.root.join("tmp/storage") %>local: service: Disk root: <%= Rails.root.join("storage") %># Use rails credentials:edit to set the AWS secrets (as aws:access_key_id|secret_access_key)# amazon:# service: S3# access_key_id: <%= Rails.application.credentials.dig(:aws, :access_key_id) %># secret_access_key: <%= Rails.application.credentials.dig(:aws, :secret_access_key) %># region: us-east-1# bucket: your_own_bucket# Remember not to checkin your GCS keyfile to a repository# google:# service: GCS# project: your_project# credentials: <%= Rails.root.join("path/to/gcs.keyfile") %># bucket: your_own_bucket# Use rails credentials:edit to set the Azure Storage secret (as azure_storage:storage_access_key)# microsoft:# service: AzureStorage# storage_account_name: your_account_name# storage_access_key: <%= Rails.application.credentials.dig(:azure_storage, :storage_access_key) %># container: your_container_name# mirror:# service: Mirror# primary: local# mirrors: [ amazon, google, microsoft ]
This time when I deployed everything worked fine.
Note: You can modify the file content based on your storage configurations
That's all.
I hope this helps
This may not fix your issue, but I had ".yaml" instead of ".yml" because I had to manually create the file "/config/storage.yml" manually and made a typo.
Hope this helps someone, as I couldn't find many results on this error.
FYI, I think the generator didn't create the storage.yml file because I was on Rails 5.1, originally and then upgraded to 5.2