Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Paperclip image uploads in Rails - Paperclip::CommandNotFoundError

Tags:

I'm using paperclip to handle image uploads to rails. it worked fine on my dev OSX machine, but now on my web server I get this error:

[paperclip] /Users/marky/bin/identify '-format' '%wx%h' '/tmp/stream,16451,2.JPG[0]' 2>/dev/null [paperclip] An error was received while processing: #<Paperclip::CommandNotFoundError: Paperclip::CommandNotFoundError> [paperclip] /Users/marky/bin/identify '-format' '%wx%h' '/tmp/stream,16451,2.JPG[0]' 2>/dev/null [paperclip] An error was received while processing: #<Paperclip::CommandNotFoundError: Paperclip::CommandNotFoundError> 

Now it's clear to me the reason; identify is actually in /usr/bin/ not /Users/marky/bin/ which is from my dev machine. I have:

Paperclip.options[:command_path] = "/usr/bin" 

in my development.rb, but I'm still getting the error. I have no idea how to fix this, can anyone help?

like image 969
Marky Avatar asked Jul 11 '10 07:07

Marky


2 Answers

Install following packages for working with imagemagick

1) apt-get install imagemagick 2) apt-get install libmagickwand-dev 3) gem install rmagick 

I think you are missing the second one.

like image 172
MKumar Avatar answered Sep 28 '22 10:09

MKumar


If you are hosting your application with Passenger, keep in mind that Passenger does not have the same $PATH variable as your logged in user. A good way to check whether Passenger can see the ImageMagick commands is to add this to one of your erb templates:

<%= `which convert` %> <%= `echo $PATH` %> 

and to compare the results with running the same commands in your terminal. Another possibility is ImageMagick can't find the libs it needs. In this case, you may need to export another variable to let ImageMagick know where the libs are:

# my config/environments/development.rb Paperclip.options[:command_path] = "DYLD_LIBRARY_PATH='/Users/jch/Library/ImageMagick-6.6.3/lib' /Users/jch/Library/ImageMagick-6.6.3/bin" 

Hope that helps -jerry

like image 30
Jerry Cheung Avatar answered Sep 28 '22 10:09

Jerry Cheung