Paperclip with JRuby

I recently adapted the application for my rails to work in JRuby. One of the issues I ran into was with Paperclip. Paperclip uses Cocaine to run command line tools such as ImageMagick, and uses Process.spawn, which results in:

Errno :: ECHILD: No child processes - No child processes
                 waitpid at org / jruby / RubyProcess.java: 512
                 waitpid at org / jruby / RubyProcess.java: 497
                 waitpid at /home/cthulhu/.rvm/gems/jruby-1.6.7.2/gems/cocaine-0.3.0/lib/cocaine/command_line/runners/process_runner.rb:21
                    call at /home/cthulhu/.rvm/gems/jruby-1.6.7.2/gems/cocaine-0.3.0/lib/cocaine/command_line/runners/process_runner.rb:9
                 execute at /home/cthulhu/.rvm/gems/jruby-1.6.7.2/gems/cocaine-0.3.0/lib/cocaine/command_line.rb:77
                     run at /home/cthulhu/.rvm/gems/jruby-1.6.7.2/gems/cocaine-0.3.0/lib/cocaine/command_line.rb:55
                     run at /home/cthulhu/.rvm/gems/jruby-1.6.7.2/gems/paperclip-3.2.0/lib/paperclip/helpers.rb:29

Is there any way to make paperclip work smoothly with JRuby? I run my application only on Linux, so I do not mind using my own linux tools like ImageMagick.

Rails 3.2.8, JRuby 1.6.7.2

+5
source share
3 answers

JRuby 1.7. caveat JRuby, Cocaine Github, JRuby. , , -

Cocaine::CommandLine.runner = Cocaine::CommandLine::BackticksRunner.new

Runners Cocaine Github.

+6

Paperclip Cocaine , - Cocaine BackticksRunner, JRuby

if RUBY_PLATFORM == 'java'
  module Cocaine
    class CommandLine
      def best_runner
        BackticksRunner.new
      end
    end
  end
end

.

+2

FWIW, I just pushed an accessory to cocaine that allows you to manually override Runner.

Cocaine::CommandLine.runner = Cocaine::CommandLine::BackticksRunner.new

I do not know why jruby reports that Process.spawn is available when it is not, but at least we have a workaround.

+2
source

All Articles