Reputation: 17981
Upgrading Rails to 5.2, and I found out that I must commit the storage.yml into version control. I don't plan to use ActiveStorage. Is there a way to disable it?
Upvotes: 38
Views: 15702
Reputation: 875
I ran into this migrating from Rails 5 to 6. I'm also not using active storage, had removed all references to it, and had tried the answer above overriding the require rails/all
idea, yet still ran into this error.
It was actually simpler to commit an empty config/storage.yml
into source. This doesn't mean you need to start using ActiveStorage anywhere in your app (to OP's original point), and will give you a more standard rails configuration, rather than worry about diverging from what require rails/all
does in future updates.
For completeness, here's the boilerplate config/storage.yml
you can add to address this issue.
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 ]
Upvotes: 0
Reputation: 831
The only solution I've found so far is in config/application.rb
, replacing:
require 'rails/all'
With:
require "rails"
# Include each railties manually, excluding `active_storage/engine`
%w(
active_record/railtie
action_controller/railtie
action_view/railtie
action_mailer/railtie
active_job/railtie
action_cable/engine
rails/test_unit/railtie
sprockets/railtie
).each do |railtie|
begin
require railtie
rescue LoadError
end
end
which is taken from Rails' source.
Upvotes: 28
Reputation: 583
Remove next line from config/application.rb
require "active_storage/engine"
Remove next line from environments config/environments/*.rb
config.active_storage.service = :local
Remove next line from app/assets/javascripts/application.js
//= require activestorage
ActiveStorage rails routes will vanish
In case there is statement require 'rails/all'
in application.rb
then you can use solution provided below where you need to require dependency by dependency and to omit active_storage
.
Upvotes: 45
Reputation: 17981
Remove lines like the following from config/environments/*.rb
config.active_storage.service = :local
Rails will then not load the yaml file.
Upvotes: 3