Skip to content
This repository has been archived by the owner on Jul 13, 2023. It is now read-only.

Errno::E2BIG: Argument list too long #1670

Closed
Davidslv opened this issue Oct 7, 2014 · 6 comments
Closed

Errno::E2BIG: Argument list too long #1670

Davidslv opened this issue Oct 7, 2014 · 6 comments

Comments

@Davidslv
Copy link

Davidslv commented Oct 7, 2014

Hello guys,
Seems I'm not the first one to have this problem #722

We just changed to sidekiq very recently (almost two weeks).
We are using:
rails 3.2.18
paperclip 4.2.0
sidekiq 3.2.5

Error message:
Argument list too long - identify -format '%wx%h,%[exif:orientation]' '/tmp/919c8b643b7133116b02fc0d9bb7df3f20141007-1108-zjkewb.jpg[0]' 2>/dev/null

This is the backtrace we get from sidekiq, hope it can be somehow helpful to debug the problem

/var/apps/shared/bundle/ruby/2.1.0/gems/cocaine-0.5.4/lib/cocaine/command_line/runners/process_runner.rb:34:in `spawn'
/var/apps/shared/bundle/ruby/2.1.0/gems/cocaine-0.5.4/lib/cocaine/command_line/runners/process_runner.rb:34:in `spawn'
/var/apps/shared/bundle/ruby/2.1.0/gems/cocaine-0.5.4/lib/cocaine/command_line/runners/process_runner.rb:22:in `block in call'
/var/apps/shared/bundle/ruby/2.1.0/gems/climate_control-0.0.3/lib/climate_control/modifier.rb:30:in `call'
/var/apps/shared/bundle/ruby/2.1.0/gems/climate_control-0.0.3/lib/climate_control/modifier.rb:30:in `run_block'
/var/apps/shared/bundle/ruby/2.1.0/gems/climate_control-0.0.3/lib/climate_control/modifier.rb:13:in `process'
/var/apps/shared/bundle/ruby/2.1.0/gems/climate_control-0.0.3/lib/climate_control.rb:6:in `modify'
/var/apps/shared/bundle/ruby/2.1.0/gems/cocaine-0.5.4/lib/cocaine/command_line/runners/process_runner.rb:44:in `with_modified_environment'
/var/apps/shared/bundle/ruby/2.1.0/gems/cocaine-0.5.4/lib/cocaine/command_line/runners/process_runner.rb:21:in `call'
/var/apps/shared/bundle/ruby/2.1.0/gems/cocaine-0.5.4/lib/cocaine/command_line.rb:122:in `execute'
/var/apps/shared/bundle/ruby/2.1.0/gems/cocaine-0.5.4/lib/cocaine/command_line.rb:79:in `run'
/var/apps/shared/bundle/ruby/2.1.0/gems/paperclip-3.5.3/lib/paperclip/helpers.rb:31:in `run'
/var/apps/shared/bundle/ruby/2.1.0/gems/paperclip-3.5.3/lib/paperclip/geometry_detector_factory.rb:17:in `geometry_string'
/var/apps/shared/bundle/ruby/2.1.0/gems/paperclip-3.5.3/lib/paperclip/geometry_detector_factory.rb:9:in `make'
/var/apps/shared/bundle/ruby/2.1.0/gems/paperclip-3.5.3/lib/paperclip/geometry.rb:26:in `from_file'
/var/apps/shared/bundle/ruby/2.1.0/gems/paperclip-3.5.3/lib/paperclip/thumbnail.rb:35:in `initialize'
/var/apps/shared/bundle/ruby/2.1.0/gems/paperclip-3.5.3/lib/paperclip/processor.rb:33:in `new'
/var/apps/shared/bundle/ruby/2.1.0/gems/paperclip-3.5.3/lib/paperclip/processor.rb:33:in `make'
/var/apps/shared/bundle/ruby/2.1.0/gems/paperclip-3.5.3/lib/paperclip/attachment.rb:439:in `block in post_process_style'
/var/apps/shared/bundle/ruby/2.1.0/gems/paperclip-3.5.3/lib/paperclip/attachment.rb:438:in `each'
/var/apps/shared/bundle/ruby/2.1.0/gems/paperclip-3.5.3/lib/paperclip/attachment.rb:438:in `inject'
/var/apps/shared/bundle/ruby/2.1.0/gems/paperclip-3.5.3/lib/paperclip/attachment.rb:438:in `post_process_style'
/var/apps/shared/bundle/ruby/2.1.0/gems/paperclip-3.5.3/lib/paperclip/attachment.rb:428:in `post_process_styles'
/var/apps/shared/bundle/ruby/2.1.0/gems/paperclip-meta-1.1.0/lib/paperclip-meta/attachment.rb:20:in `post_process_styles_with_meta_data'
/var/apps/shared/bundle/ruby/2.1.0/gems/paperclip-3.5.3/lib/paperclip/attachment.rb:421:in `block (2 levels) in post_process'
/var/apps/shared/bundle/ruby/2.1.0/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:403:in `_run__361426672036209974__image_post_process__4391166143979805692__callbacks'
/var/apps/shared/bundle/ruby/2.1.0/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:405:in `__run_callback'
/var/apps/shared/bundle/ruby/2.1.0/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:385:in `_run_image_post_process_callbacks'
/var/apps/shared/bundle/ruby/2.1.0/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:81:in `run_callbacks'
/var/apps/shared/bundle/ruby/2.1.0/gems/paperclip-3.5.3/lib/paperclip/callbacks.rb:26:in `run_paperclip_callbacks'
/var/apps/shared/bundle/ruby/2.1.0/gems/paperclip-3.5.3/lib/paperclip/attachment.rb:419:in `block in post_process'
/var/apps/shared/bundle/ruby/2.1.0/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:403:in `_run__361426672036209974__post_process__4391166143979805692__callbacks'
/var/apps/shared/bundle/ruby/2.1.0/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:405:in `__run_callback'
/var/apps/shared/bundle/ruby/2.1.0/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:385:in `_run_post_process_callbacks'
/var/apps/shared/bundle/ruby/2.1.0/gems/activesupport-3.2.17/lib/active_support/callbacks.rb:81:in `run_callbacks'
/var/apps/shared/bundle/ruby/2.1.0/gems/paperclip-3.5.3/lib/paperclip/callbacks.rb:26:in `run_paperclip_callbacks'
/var/apps/shared/bundle/ruby/2.1.0/gems/paperclip-3.5.3/lib/paperclip/attachment.rb:418:in `post_process'
/var/apps/shared/bundle/ruby/2.1.0/gems/newrelic_rpm-3.7.3.204/lib/new_relic/agent/method_tracer.rb:549:in `block in post_process_with_trace_Paperclip_name_post_process'
/var/apps/shared/bundle/ruby/2.1.0/gems/newrelic_rpm-3.7.3.204/lib/new_relic/agent/method_tracer.rb:281:in `trace_execution_scoped'
/var/apps/shared/bundle/ruby/2.1.0/gems/newrelic_rpm-3.7.3.204/lib/new_relic/agent/method_tracer.rb:544:in `post_process_with_trace_Paperclip_name_post_process'
/var/apps/shared/bundle/ruby/2.1.0/gems/paperclip-3.5.3/lib/paperclip/attachment.rb:112:in `assign'
/var/apps/shared/bundle/ruby/2.1.0/gems/newrelic_rpm-3.7.3.204/lib/new_relic/agent/method_tracer.rb:549:in `block in assign_with_trace_Paperclip_name_assign'
/var/apps/shared/bundle/ruby/2.1.0/gems/newrelic_rpm-3.7.3.204/lib/new_relic/agent/method_tracer.rb:281:in `trace_execution_scoped'
/var/apps/shared/bundle/ruby/2.1.0/gems/newrelic_rpm-3.7.3.204/lib/new_relic/agent/method_tracer.rb:544:in `assign_with_trace_Paperclip_name_assign'
/var/apps/shared/bundle/ruby/2.1.0/gems/paperclip-3.5.3/lib/paperclip/has_attached_file.rb:65:in `block in define_setter'
/var/apps/releases/20141007163101/app/models/photo.rb:111:in `download_image'
/var/apps/releases/20141007163101/app/workers/download_photo_worker.rb:7:in `perform'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/processor.rb:52:in `block (2 levels) in process'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/middleware/chain.rb:122:in `call'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/middleware/chain.rb:122:in `block in invoke'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-statsd-0.1.3/lib/sidekiq/statsd/server_middleware.rb:38:in `block (2 levels) in call'
/var/apps/shared/bundle/ruby/2.1.0/gems/statsd-ruby-1.2.1/lib/statsd.rb:232:in `time'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-statsd-0.1.3/lib/sidekiq/statsd/server_middleware.rb:37:in `block in call'
/var/apps/shared/bundle/ruby/2.1.0/gems/statsd-ruby-1.2.1/lib/statsd.rb:67:in `easy'
/var/apps/shared/bundle/ruby/2.1.0/gems/statsd-ruby-1.2.1/lib/statsd.rb:248:in `batch'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-statsd-0.1.3/lib/sidekiq/statsd/server_middleware.rb:35:in `call'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'
/var/apps/shared/bundle/ruby/2.1.0/gems/newrelic_rpm-3.7.3.204/lib/new_relic/agent/instrumentation/sidekiq.rb:30:in `block in call'
/var/apps/shared/bundle/ruby/2.1.0/gems/newrelic_rpm-3.7.3.204/lib/new_relic/agent/instrumentation/controller_instrumentation.rb:335:in `perform_action_with_newrelic_trace'
/var/apps/shared/bundle/ruby/2.1.0/gems/newrelic_rpm-3.7.3.204/lib/new_relic/agent/instrumentation/sidekiq.rb:21:in `call'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/middleware/server/active_record.rb:6:in `call'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/middleware/server/retry_jobs.rb:74:in `call'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-failures-0.4.3/lib/sidekiq/failures/middleware.rb:9:in `call'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/middleware/server/logging.rb:11:in `block in call'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/logging.rb:22:in `with_context'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/middleware/server/logging.rb:7:in `call'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/middleware/chain.rb:124:in `block in invoke'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/middleware/chain.rb:127:in `call'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/middleware/chain.rb:127:in `invoke'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/processor.rb:51:in `block in process'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/processor.rb:94:in `stats'
/var/apps/shared/bundle/ruby/2.1.0/gems/sidekiq-3.2.5/lib/sidekiq/processor.rb:50:in `process'
/var/apps/shared/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `public_send'
/var/apps/shared/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in `dispatch'
/var/apps/shared/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/calls.rb:122:in `dispatch'
/var/apps/shared/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/actor.rb:322:in `block in handle_message'
/var/apps/shared/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/actor.rb:416:in `block in task'
/var/apps/shared/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:55:in `block in initialize'
/var/apps/shared/bundle/ruby/2.1.0/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:13:in `block in create'

Thank you

@Davidslv
Copy link
Author

Davidslv commented Nov 6, 2014

We haven't seen this error since we lowered our number of threads (we are using AWS m3.large - for reference)

  1. We reduced the number of Threads, we had 20, got down to 10
  2. We tweaked our queues so that worker would have is own queue
  3. We upgraded to latest paperclip

Although point 3 was done this week and we haven't seen anything related with this issue by just doing 1 and 2.

@pch
Copy link

pch commented Nov 8, 2014

I've run into the same problem. We're using Paperclip with Sidekiq and after a while it ends up throwing Argument list too long. After some debugging & profiling with ObjectSpace I found that Paperclip (or Cocaine) ends up expanding $PATH infinitely when concurrent jobs are running:

Paperclip.options[:command_path] = '/usr/local/bin'
/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/bin

Leaving Paperclip.options[:command_path] as nil seems to resolve it, although I haven't done enough testing to be sure.

paperclip (4.2.0)
cocaine (0.5.4)
climate_control (0.0.3)

@pch
Copy link

pch commented Nov 8, 2014

The problem is this line:

Cocaine::CommandLine.path = [Cocaine::CommandLine.path, command_path].flatten.compact.uniq

https://github.com/thoughtbot/paperclip/blob/master/lib/paperclip/helpers.rb#L27

Here's the relevant method in Cocaine:

     def path=(supplemental_path)
        @supplemental_path = supplemental_path
        @supplemental_environment ||= {}

        @supplemental_environment['PATH'] = (Array(supplemental_path) + [ENV['PATH']]).join(File::PATH_SEPARATOR)
      end

When multiple workers set the value simultaneously, it ends up prepending supplemental_path to @supplemental_environment['PATH'] infinitely, which results in Argument list too long when the value exceeds getconf ARG_MAX.

My quick and dirty fix is to set CommandLine.path only when it's nil. It's hacky, but it seems to fix the problem. Here's my monkeypatch:

module Paperclip
  module Helpers
    def run(cmd, arguments = "", interpolation_values = {}, local_options = {})
      command_path = options[:command_path]

      # set path only when it's nil
      Cocaine::CommandLine.path ||= command_path

      if logging? && (options[:log_command] || local_options[:log_command])
        local_options = local_options.merge(:logger => logger)
      end
      Cocaine::CommandLine.new(cmd, arguments, local_options).run(interpolation_values)
    end
  end
end

@obitum
Copy link

obitum commented Jan 18, 2015

This might not be an issue since the latest release of Cocaine specifically this commit: thoughtbot/cocaine@e61a678

@nakamurakengo
Copy link

I was having a same issue with Rails 4.2 + paperclip 4.2.1 + cocaine 0.5.5.

I used the pch's patch. As @pch said, the problem was in this line.

Cocaine::CommandLine.path = [Cocaine::CommandLine.path, command_path].flatten.compact.uniq

Cocaine::CommandLine.path returns a string like "/usr/bin/:/usr/local/bin/", and command_path returns an array like ["/usr/bin", "/usr/local/bin"].
The line joins Cocaine::CommandLine.path and command_path, but since Cocaine::CommandLine.path is a string, it becomes "/usr/bin/:/usr/local/bin/:/usr/bin/:/usr/local/bin/". This leads to Errno::E2BIG: Argument list too long error after a few thousand loops.

@tute tute closed this as completed in f7aa320 Apr 12, 2016
@tute
Copy link
Contributor

tute commented Apr 12, 2016

Fixed in master. Thanks for reporting!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants