Question

I was having some problems getting the dragonfly gem to play nicely with passenger. Passenger doesn't seem to use the current $PATH so it can't find the convert binary. I've added some configuration to dragonfly which seems to solve the issue:

require 'dragonfly/rails/images'

Dragonfly[:images].configure do |c|
  c.convert_command  = "/usr/local/bin/convert" # defaults to "convert"
  c.identify_command = "/usr/local/bin/convert" # defaults to "convert"
end

but the gem i'm working on is going to be used as an engine and it's going to be a real pain to have to manually set the location to the imagemagick utilities for each install if passenger is used, is there a better solution to automatically specify the location to convert if available?

Was it helpful?

Solution

Hey mario, try something like this. I've been using it to resolve pathing problems with passenger+paperclip+rmagick.

path = `which convert`.strip.gsub('convert','').presence || "/usr/local/bin/"

It should return /usr/local/bin when convert isn't in the path or unable to be found.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top