Capistrano部署期间nil:NilClass的载波未定义方法“ []”

时间:2019-01-08 13:07:22

标签: ruby-on-rails capistrano carrierwave

我正在尝试使用Capistrano部署新版本,并且在asset:precompile任务期间出现错误

undefined method []' for nil:NilClass

完整的堆栈跟踪如下:

/home/deploy/bikeramp/releases/20190108123149/config/initializers/carrierwave.rb:5:in `block in <top (required)>'
/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 `<top (required)>'
/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 <class:Engine>'
/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 <class:Engine>'
/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 `<top (required)>'
/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 `<top (required)>'
/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 <top (required)>'
/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 `<top (required)>'
/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 `<main>'
/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 `<main>'
Tasks: TOP => environment
(See full trace by running task with --trace)

载波配置

config/initializers/carrierwave.rb

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" => "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

该错误消息指向第5行,即config.enable_processing = true,所以我不确定为什么会收到此错误。 我究竟做错了什么?我想念什么吗?

0 个答案:

没有答案