title: Carrierwave undefined method `[]' for nil:NilClass during Capistrano deployment
body: <p>I am trying to deploy a new release using Capistrano and I am getting an error during asset:precompile task</p>
  
  <p><code>undefined method []' for nil:NilClass</code></p>
  
  <p>The full stacktrace is as follows:</p>
  
  <pre><code>/home/deploy/bikeramp/releases/20190108123149/config/initializers/carrierwave.rb:5:in `block in &lt;top (required)&gt;'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/carrierwave-1.3.1/lib/carrierwave/uploader/configuration.rb:161:in `configure'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/carrierwave-1.3.1/lib/carrierwave.rb:14:in `configure'
  /home/deploy/bikeramp/releases/20190108123149/config/initializers/carrierwave.rb:1:in `&lt;top (required)&gt;'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:285:in `load'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:285:in `block in load'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:285:in `load'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/engine.rb:657:in `block in load_config_initializer'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/notifications.rb:170:in `instrument'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/engine.rb:656:in `load_config_initializer'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/engine.rb:614:in `block (2 levels) in &lt;class:Engine&gt;'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/engine.rb:613:in `each'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/engine.rb:613:in `block in &lt;class:Engine&gt;'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/initializable.rb:32:in `instance_exec'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/initializable.rb:32:in `run'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/initializable.rb:61:in `block in run_initializers'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/initializable.rb:50:in `each'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/initializable.rb:50:in `tsort_each_child'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/initializable.rb:60:in `run_initializers'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/application.rb:361:in `initialize!'
  /home/deploy/bikeramp/releases/20190108123149/config/environment.rb:5:in `&lt;top (required)&gt;'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `block in require'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:257:in `load_dependency'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/activesupport-5.2.2/lib/active_support/dependencies.rb:291:in `require'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/application.rb:337:in `require_environment!'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/railties-5.2.2/lib/rails/application.rb:520:in `block in run_tasks_blocks'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/sprockets-rails-3.2.1/lib/sprockets/rails/task.rb:62:in `block (2 levels) in define'
  /home/deploy/bikeramp/shared/bundle/ruby/2.5.0/gems/rake-12.3.2/exe/rake:27:in `&lt;top (required)&gt;'
  /home/deploy/.rvm/gems/ruby-2.5.1/gems/bundler-1.17.1/lib/bundler/cli/exec.rb:74:in `load'
  /home/deploy/.rvm/gems/ruby-2.5.1/gems/bundler-1.17.1/lib/bundler/cli/exec.rb:74:in `kernel_load'
  /home/deploy/.rvm/gems/ruby-2.5.1/gems/bundler-1.17.1/lib/bundler/cli/exec.rb:28:in `run'
  /home/deploy/.rvm/gems/ruby-2.5.1/gems/bundler-1.17.1/lib/bundler/cli.rb:463:in `exec'
  /home/deploy/.rvm/gems/ruby-2.5.1/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
  /home/deploy/.rvm/gems/ruby-2.5.1/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
  /home/deploy/.rvm/gems/ruby-2.5.1/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor.rb:387:in `dispatch'
  /home/deploy/.rvm/gems/ruby-2.5.1/gems/bundler-1.17.1/lib/bundler/cli.rb:27:in `dispatch'
  /home/deploy/.rvm/gems/ruby-2.5.1/gems/bundler-1.17.1/lib/bundler/vendor/thor/lib/thor/base.rb:466:in `start'
  /home/deploy/.rvm/gems/ruby-2.5.1/gems/bundler-1.17.1/lib/bundler/cli.rb:18:in `start'
  /home/deploy/.rvm/gems/ruby-2.5.1/gems/bundler-1.17.1/exe/bundle:30:in `block in &lt;top (required)&gt;'
  /home/deploy/.rvm/gems/ruby-2.5.1/gems/bundler-1.17.1/lib/bundler/friendly_errors.rb:124:in `with_friendly_errors'
  /home/deploy/.rvm/gems/ruby-2.5.1/gems/bundler-1.17.1/exe/bundle:22:in `&lt;top (required)&gt;'
  /home/deploy/.rvm/gems/ruby-2.5.1/bin/bundle:23:in `load'
  /home/deploy/.rvm/gems/ruby-2.5.1/bin/bundle:23:in `&lt;main&gt;'
  /home/deploy/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:15:in `eval'
  /home/deploy/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:15:in `&lt;main&gt;'
  Tasks: TOP =&gt; environment
  (See full trace by running task with --trace)
  </code></pre>
  
  <p>Carrierwave config</p>
  
  <p><code>config/initializers/carrierwave.rb</code></p>
  
  <pre><code>CarrierWave.configure do |config|
    if Rails.env.production? || Rails.env.development?
      config.asset_host = 'https://some_host'
      config.fog_provider = 'fog/aws'
      config.enable_processing = true
      config.fog_directory = Rails.application.credentials.aws[:bucket] # required
      config.fog_public = false # optional, defaults to true
      config.fog_attributes = { "Cache-Control" =&gt; "max-age=315576000" } # optional, defaults to {}
  
      config.fog_credentials = {
        provider: "AWS", # required
        aws_access_key_id: Rails.application.credentials.aws[:access_key_id], # required
        aws_secret_access_key: Rails.application.credentials.aws[:secret_access_key], # required
        region: Rails.application.credentials.aws[:region] # optional, defaults to 'us-east-1'
      }
      config.storage = :fog
    else
      config.enable_processing = false
      config.storage = :file
    end
  end
  </code></pre>
  
  <p>The error message is pointing to line 5 which is <code>config.enable_processing = true</code> so I am not sure why I am getting this error.
  What am I doing wrong? Am I missing something?</p>