Fail to build rails container during assets precompile

Feature(s) impacted

Rails deployment to production env in docker containers

Observed behavior

Build fails while trying to precompile assets in assets

Expected behavior

Build should succeed…

Failure Logs

Context

Just installed forest to complete onboarding production and it fails when precompiling assets. Everything deploys fine when I remove forest again.

The underlying culprit is the active storage module trying to access DO Spaces via s3 sdk.

Not sure why adding forest to the gem file is making this fail, but it does make it undeployable at the moment.

Anyone had a similar issue with rails?

  • Project name: LeanBOD
  • Team name: BOD Company
  • Environment name: Production
  • Agent type & version: Forest Liana 7.8

Hi @Cluster444 , and welcome to our community :wave:,

Could you please share the error logs ?

Thanks.

Sure. here’s the stack trace that gets dumped. There’s nothing forest specfic in there I don’t think, but the fact that it’s hitting this in the first place is what’s wrong. That’s the config for ActiveStorage via DigitalOcean being triggered, which doesn’t happen if I remove forest from the Gemfile.

Is there an initializer in the gem that is tripping this up?

Aws::Errors::MissingRegionError: No region was provided. Configure the `:region` option or export the region name to ENV['AWS_REGION']
/bundle/ruby/3.1.0/gems/aws-sdk-s3-1.114.0/lib/aws-sdk-s3/plugins/s3_signer.rb:23:in `block in <class:S3Signer>'
/bundle/ruby/3.1.0/gems/aws-sdk-core-3.132.0/lib/seahorse/client/configuration.rb:72:in `call'
/bundle/ruby/3.1.0/gems/aws-sdk-core-3.132.0/lib/seahorse/client/configuration.rb:219:in `block in resolve_defaults'
/bundle/ruby/3.1.0/gems/aws-sdk-core-3.132.0/lib/seahorse/client/configuration.rb:59:in `each'
/bundle/ruby/3.1.0/gems/aws-sdk-core-3.132.0/lib/seahorse/client/configuration.rb:59:in `each'
/bundle/ruby/3.1.0/gems/aws-sdk-core-3.132.0/lib/seahorse/client/configuration.rb:218:in `resolve_defaults'
/bundle/ruby/3.1.0/gems/aws-sdk-core-3.132.0/lib/seahorse/client/configuration.rb:211:in `value_at'
/bundle/ruby/3.1.0/gems/aws-sdk-core-3.132.0/lib/seahorse/client/configuration.rb:191:in `block in resolve'
/usr/local/lib/ruby/3.1.0/set.rb:511:in `each_key'
/usr/local/lib/ruby/3.1.0/set.rb:511:in `each'
/bundle/ruby/3.1.0/gems/aws-sdk-core-3.132.0/lib/seahorse/client/configuration.rb:191:in `resolve'
/bundle/ruby/3.1.0/gems/aws-sdk-core-3.132.0/lib/seahorse/client/configuration.rb:179:in `apply_defaults'
/bundle/ruby/3.1.0/gems/aws-sdk-core-3.132.0/lib/seahorse/client/configuration.rb:152:in `build!'
/bundle/ruby/3.1.0/gems/aws-sdk-core-3.132.0/lib/seahorse/client/base.rb:65:in `build_config'
/bundle/ruby/3.1.0/gems/aws-sdk-core-3.132.0/lib/seahorse/client/base.rb:22:in `initialize'
/bundle/ruby/3.1.0/gems/aws-sdk-s3-1.114.0/lib/aws-sdk-s3/client.rb:435:in `initialize'
/bundle/ruby/3.1.0/gems/aws-sdk-core-3.132.0/lib/seahorse/client/base.rb:102:in `new'
/bundle/ruby/3.1.0/gems/aws-sdk-s3-1.114.0/lib/aws-sdk-s3/resource.rb:28:in `initialize'
/bundle/ruby/3.1.0/gems/activestorage-7.0.4/lib/active_storage/service/s3_service.rb:16:in `new'
/bundle/ruby/3.1.0/gems/activestorage-7.0.4/lib/active_storage/service/s3_service.rb:16:in `initialize'
/bundle/ruby/3.1.0/gems/activestorage-7.0.4/lib/active_storage/service.rb:61:in `new'
/bundle/ruby/3.1.0/gems/activestorage-7.0.4/lib/active_storage/service.rb:61:in `build'
/bundle/ruby/3.1.0/gems/activestorage-7.0.4/lib/active_storage/service/configurator.rb:17:in `build'
/bundle/ruby/3.1.0/gems/activestorage-7.0.4/lib/active_storage/service/registry.rb:13:in `block in fetch'
/bundle/ruby/3.1.0/gems/activestorage-7.0.4/lib/active_storage/service/registry.rb:11:in `fetch'
/bundle/ruby/3.1.0/gems/activestorage-7.0.4/lib/active_storage/service/registry.rb:11:in `fetch'
/bundle/ruby/3.1.0/gems/activestorage-7.0.4/lib/active_storage/engine.rb:155:in `block (2 levels) in <class:Engine>'
/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/lazy_load_hooks.rb:95:in `class_eval'
/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/lazy_load_hooks.rb:95:in `block in execute_hook'
/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/lazy_load_hooks.rb:85:in `with_execution_control'
/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/lazy_load_hooks.rb:90:in `execute_hook'
/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/lazy_load_hooks.rb:76:in `block in run_load_hooks'
/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/lazy_load_hooks.rb:75:in `each'
/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/lazy_load_hooks.rb:75:in `run_load_hooks'
/bundle/ruby/3.1.0/gems/activestorage-7.0.4/app/models/active_storage/blob.rb:410:in `<top (required)>'
/bundle/ruby/3.1.0/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:27:in `require'
/bundle/ruby/3.1.0/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:27:in `require'
/bundle/ruby/3.1.0/gems/forest_liana-7.8.0/lib/forest_liana/engine.rb:82:in `eager_load_active_record_descendants'
/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/railtie.rb:226:in `public_send'
/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/railtie.rb:226:in `method_missing'
/bundle/ruby/3.1.0/gems/forest_liana-7.8.0/lib/forest_liana/engine.rb:100:in `block in <class:Engine>'
/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/lazy_load_hooks.rb:92:in `block in execute_hook'
/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/lazy_load_hooks.rb:85:in `with_execution_control'
/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/lazy_load_hooks.rb:90:in `execute_hook'
/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/lazy_load_hooks.rb:76:in `block in run_load_hooks'
/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/lazy_load_hooks.rb:75:in `each'
/bundle/ruby/3.1.0/gems/activesupport-7.0.4/lib/active_support/lazy_load_hooks.rb:75:in `run_load_hooks'
/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/application/finisher.rb:87:in `block in <module:Finisher>'
/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/initializable.rb:32:in `instance_exec'
/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/initializable.rb:32:in `run'
/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/initializable.rb:61:in `block in run_initializers'
/usr/local/lib/ruby/3.1.0/tsort.rb:228:in `block in tsort_each'
/usr/local/lib/ruby/3.1.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
/usr/local/lib/ruby/3.1.0/tsort.rb:431:in `each_strongly_connected_component_from'
/usr/local/lib/ruby/3.1.0/tsort.rb:349:in `block in each_strongly_connected_component'
/usr/local/lib/ruby/3.1.0/tsort.rb:347:in `each'
/usr/local/lib/ruby/3.1.0/tsort.rb:347:in `call'
/usr/local/lib/ruby/3.1.0/tsort.rb:347:in `each_strongly_connected_component'
/usr/local/lib/ruby/3.1.0/tsort.rb:226:in `tsort_each'
/usr/local/lib/ruby/3.1.0/tsort.rb:205:in `tsort_each'
/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/initializable.rb:60:in `run_initializers'
/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/application.rb:372:in `initialize!'
/app/config/environment.rb:5:in `<top (required)>'
/bundle/ruby/3.1.0/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:35:in `require'
/bundle/ruby/3.1.0/gems/zeitwerk-2.6.0/lib/zeitwerk/kernel.rb:35:in `require'
/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/application.rb:348:in `require_environment!'
/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/application.rb:511:in `block in run_tasks_blocks'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/bundle/ruby/3.1.0/gems/sprockets-rails-3.4.2/lib/sprockets/rails/task.rb:61:in `block (2 levels) in define'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:243:in `block in invoke_prerequisites'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `each'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:241:in `invoke_prerequisites'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:218:in `block in invoke_with_call_chain'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'
/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'
/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'
/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'
/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/commands/rake/rake_command.rb:18:in `perform'
/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/command.rb:51:in `invoke'
/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/commands.rb:18:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'

It seems that the issue comes from the absence of AWS_REGION env variable.

Do you have this env variable in production ?