Permission denied @ rb_sysopen from Ruby gem writing to filesystem

Viewed 419

Ruby 2.4.0

Rails 5.2.3

I have a Rails ActiveJob generating an xlsx report using the Axlsx gem. When it tries to write the file to the file system with:

axlsx.serialize("#{Rails.root}/tmp/#{@report_name}.xlsx")

It gives the following error: Errno::EACCES (Permission denied @ rb_sysopen - /var/storage/my_app/releases/20200610141310/tmp/report_for_call_25_20200610142531.xlsx)

Full trace:

E, [2020-06-10T14:25:31.090477 #23375] ERROR -- : [ActiveJob] [GenerateReportJob] [013852d1-8127-4db4-90ae-895c998f34c7] Error performing GenerateReportJob (Job ID: 013852d1-8127-4db4-90ae-895c998f34c7) from Async(default) in 30.2ms: 
Errno::EACCES (Permission denied @ rb_sysopen - /var/storage/my_app/releases/20200610141310/tmp/report_for_call_25_20200610142531.xlsx):
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/rubyzip-1.3.0/lib/zip/output_stream.rb:36:in `initialize'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/rubyzip-1.3.0/lib/zip/output_stream.rb:36:in `new'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/rubyzip-1.3.0/lib/zip/output_stream.rb:36:in `initialize'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/rubyzip-1.3.0/lib/zip/output_stream.rb:52:in `new'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/rubyzip-1.3.0/lib/zip/output_stream.rb:52:in `open'
/var/storage/my_app/shared/bundle/ruby/2.4.0/bundler/gems/axlsx-2891eb2246d9/lib/axlsx/package.rb:104:in `serialize'
/var/storage/my_app/releases/20200610141310/lib/my_app/generate_xml_report.rb:87:in `create_excel'
/var/storage/my_app/releases/20200610141310/lib/my_app/generate_xml_report.rb:59:in `generate_report'
/var/storage/my_app/releases/20200610141310/app/jobs/generate_report_job.rb:6:in `perform'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activejob-5.2.3/lib/active_job/execution.rb:39:in `block in perform_now'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:109:in `block in run_callbacks'
/var/storage/my_app/releases/20200610141310/app/jobs/generate_report_job.rb:23:in `around_report_job'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/i18n-1.7.0/lib/i18n.rb:297:in `with_locale'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activejob-5.2.3/lib/active_job/translation.rb:9:in `block (2 levels) in '
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:118:in `instance_exec'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activejob-5.2.3/lib/active_job/logging.rb:26:in `block (4 levels) in '
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.3/lib/active_support/notifications.rb:168:in `block in instrument'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.3/lib/active_support/notifications/instrumenter.rb:23:in `instrument'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.3/lib/active_support/notifications.rb:168:in `instrument'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activejob-5.2.3/lib/active_job/logging.rb:25:in `block (3 levels) in '
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activejob-5.2.3/lib/active_job/logging.rb:46:in `block in tag_logger'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.3/lib/active_support/tagged_logging.rb:71:in `block in tagged'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.3/lib/active_support/tagged_logging.rb:28:in `tagged'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.3/lib/active_support/tagged_logging.rb:71:in `tagged'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activejob-5.2.3/lib/active_job/logging.rb:46:in `tag_logger'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activejob-5.2.3/lib/active_job/logging.rb:22:in `block (2 levels) in '
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:118:in `instance_exec'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:136:in `run_callbacks'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activejob-5.2.3/lib/active_job/execution.rb:38:in `perform_now'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activejob-5.2.3/lib/active_job/execution.rb:24:in `block in execute'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:109:in `block in run_callbacks'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activejob-5.2.3/lib/active_job/railtie.rb:28:in `block (4 levels) in '
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.3/lib/active_support/execution_wrapper.rb:87:in `wrap'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.3/lib/active_support/reloader.rb:73:in `block in wrap'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.3/lib/active_support/execution_wrapper.rb:87:in `wrap'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.3/lib/active_support/reloader.rb:72:in `wrap'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activejob-5.2.3/lib/active_job/railtie.rb:27:in `block (3 levels) in '
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:118:in `instance_exec'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:118:in `block in run_callbacks'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activesupport-5.2.3/lib/active_support/callbacks.rb:136:in `run_callbacks'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activejob-5.2.3/lib/active_job/execution.rb:22:in `execute'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/activejob-5.2.3/lib/active_job/queue_adapters/async_adapter.rb:70:in `perform'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/concurrent-ruby-1.1.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:348:in `run_task'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/concurrent-ruby-1.1.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:337:in `block (3 levels) in create_worker'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/concurrent-ruby-1.1.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:320:in `loop'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/concurrent-ruby-1.1.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:320:in `block (2 levels) in create_worker'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/concurrent-ruby-1.1.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:319:in `catch'
/var/storage/my_app/shared/bundle/ruby/2.4.0/gems/concurrent-ruby-1.1.5/lib/concurrent/executor/ruby_thread_pool_executor.rb:319:in `block in create_worker'

The Rails app runs under the user 'app'.

The permissions on the tmp folder are: lrwxrwxrwx 1 app app

I also have a development server running basically the exact setup and this issue is not happening.

Can anyone shed some light on why this is happening?

0 Answers
Related