thoughtbot / cocaine

A small library for doing (command) lines.
https://robots.thoughtbot.com
Other
785 stars 55 forks source link

Rails 4 Paperclip 4.1 Ruby 2.1.1 Cover Paperclip::Errors::NotIdentifiedByImageMagickError #65

Closed asecondwill closed 10 years ago

asecondwill commented 10 years ago

I was merrily chatting to my self over on https://github.com/thoughtbot/cocaine/issues/28 when i realised the ticket was closed. so reposted here. Appologies if that was the wrong thing to do.

I'm using paperclip 4.1 and rails 4.0.2 & ruby 2.1.1 - i get the error

Cover Paperclip::Errors::NotIdentifiedByImageMagickError

I am running on osx 10.9, and i've checked my imagemagick by doing:

➜  rails git:(aa) ✗ which identify                          
/usr/local/bin/identify

I've got

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

set right at the top of my development.rb environment

Somebody saved themselves with this in the application.rb:

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

but that didn't work for me.

I saw that somebody found running:

brew install libtool --universal
brew link libtool
or 
brew unlink libtool && brew link libtool
Unlinking /usr/local/Cellar/libtool/2.4.2... 0 symlinks removed
Linking /usr/local/Cellar/libtool/2.4.2... 17 symlinks created

helped them out, but it didn't make any difference for me.

I tried

brew install --force jpeg
brew update && brew upgrade `brew outdated`

from https://github.com/thoughtbot/paperclip/issues/1205

which all happened 1st time except: Error: Permission denied - /usr/local/Cellar/libiconv/1.14

Ill check that out and report back.

So i got past that with sudo chown -Rwhoami/usr/local but the error persist.

Just found https://github.com/thoughtbot/paperclip/issues/1289 ticket, where some people had issues with a custom geometry method. I don't have one of those, so not that.

I turned on the logs

Paperclip.options[:log] = true 
Paperclip.options[:log_command] = true 

and here is the output:

Started PATCH "/helm/providers/10-test-87" for 127.0.0.1 at 2014-05-15 15:57:29 +1000
Processing by Helm::ProvidersController#update as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"NsoEuLpef3Lst9T6QRSRO4N61Haixt3HwIPO9vql36s=", "provider"=>{"name"=>"test 87", "description"=>"", "address"=>"Level 1, 27 Belgrave Street", "suburb"=>"Manly", "state"=>"New South Wales", "postcode"=>"2095", "phone"=>"61424366468", "website"=>"http://www.theraceguide.com.au", "cover"=>#<ActionDispatch::Http::UploadedFile:0x00000108491c78 @tempfile=#<Tempfile:/var/folders/qt/cvfl_0892yb625qkq7ppt14h0000gq/T/RackMultipart20140515-32533-1pm40me>, @original_filename="happydog.jpg", @content_type="image/jpeg", @headers="Content-Disposition: form-data; name=\"provider[cover]\"; filename=\"happydog.jpg\"\r\nContent-Type: image/jpeg\r\n">, "delete_cover"=>"0"}, "commit"=>"Save Settings", "id"=>"10-test-87"}
  AdminUser Load (0.8ms)  SELECT "admin_users".* FROM "admin_users" WHERE "admin_users"."id" = 2 ORDER BY "admin_users"."id" ASC LIMIT 1
  User Load (0.7ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 18 ORDER BY "users"."id" ASC LIMIT 1
  Provider Load (4.1ms)  SELECT "providers".* FROM "providers" WHERE "providers"."id" = $1 ORDER BY "providers"."id" ASC LIMIT 1  [["id", 10]]
   (0.2ms)  BEGIN
Command :: file -b --mime-type '/var/folders/qt/cvfl_0892yb625qkq7ppt14h0000gq/T/1ac677d46634f25fd48ab67499e3d1e720140515-32533-17br10g'
Command :: identify -format '%wx%h,%[exif:orientation]' '/var/folders/qt/cvfl_0892yb625qkq7ppt14h0000gq/T/c7528087ad463bffc45a3f587db01e0420140515-32533-jzu2d3[0]' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
Command :: identify -format '%wx%h,%[exif:orientation]' '/var/folders/qt/cvfl_0892yb625qkq7ppt14h0000gq/T/c7528087ad463bffc45a3f587db01e0420140515-32533-jzu2d3[0]' 2>/dev/null
[paperclip] An error was received while processing: #<Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError>
Command :: file -b --mime-type '/var/folders/qt/cvfl_0892yb625qkq7ppt14h0000gq/T/eebe1f6bcaba7765c8e20cc93c4fd8b420140515-32533-sfvsxj'
asecondwill commented 10 years ago

closing this as its a homebrew issue with imagemagick / mavericks.

running

identify -format '%wx%h,1' 'dog.jpg'

gives me errors like

identify: unable to load module `/usr/local/Cellar/imagemagick/6.8.9-1/lib/ImageMagick//modules-Q16/coders/jpeg.la': file not found @ error/module.c/OpenModule/1282.

great.

amitfriedman12 commented 9 years ago

Had same issue with image_magic that was breaking our paperclip functionality in production, but not in development (weird, I know). Yet even after removing imagemagick from our gemfile and Gemfile.lock locally (running bundle install and all that stuff) and then deploying back to production on heroku, the error persisted in production! (weird, I know).

What ended up doing the trick was running: $ heroku repo:purge_cache -a myAppName (Taken from: https://github.com/heroku/heroku-repo#purge_cache)

When you deploy your app, Heroku caches some things like your assets and installed gems in order to speed up deployment. Although this is a great feature, it can have side-effects sometimes, and in this case, it seems that something about the imagemagick gem got "stuck" in production's cache, which is why purging solved the issue for us (since purging will make your app build itself from scratch on your next deployment)

mikesmayer commented 9 years ago

@asecondwill did you ever find a solution to this issue?

asecondwill commented 9 years ago

Hi @mikesmayer - Yes i did get past it. It was with image magic. I can't remember exactly how it got fixed except it was a case of rebuilding IM to get the file type support.

http://stackoverflow.com/questions/23665735/cover-papercliperrorsnotidentifiedbyimagemagickerror http://stackoverflow.com/questions/9586048/imagemagick-no-decode-delegate

banavasi commented 9 years ago

i have the same issue but its recognizing the .gif but not other formats i have installed all the dependencies