Dan
Dan

Reputation: 3377

Upload with CarrierWave is resulting in "no such file" error

I just started playing with CarrierWave and am having trouble getting it to behave.

After setting everything up as described in Rails Casts, I am getting the following error: No such file or directory - identify -quiet -ping /tmp/mini_magick20130519-13712-lxhans.jpg NOTE: I am aware of the typo in that Rails Cast and that issue does not exist in my code.

In my dev environment, I've installed the libmagickwand-dev package, running Rails 3.2.9, and Ruby 1.9.3p194, among other things. My Gemfile includes mini_magick.

The request being passed to the server is this:

{"utf8"=>"✓",
 "authenticity_token"=>"8ugcdkjOy/5yeodhuTgMXYdrXlcu2xPjxWTvvRwKnWM=",
 "organization"=>{"logo"=>#<ActionDispatch::Http::UploadedFile:0x0000000426c3d0 @original_filename="leather-tshirt-weird-square.jpg",
 @content_type="image/jpeg",
 @headers="Content-Disposition: form-data; name=\"organization[logo]\"; filename=\"leather-tshirt-weird-square.jpg\"\r\nContent-Type: image/jpeg\r\n",
 @tempfile=#<File:/tmp/RackMultipart20130519-13712-1uvmtem>>,
 "name"=>"Test Org",
 "description"=>"blah",
 "timezone"=>"1"},
 "commit"=>"Create Organization"}

The full trace is located here: http://pastebin.com/dW5j9NLt

After initially trying some more advanced functionality, I dumbed the code down to the following and am still having no luck:

class LogoUploader < CarrierWave::Uploader::Base

  include CarrierWave::MiniMagick

  storage :file

  version :thumb do
     process :resize_to_limit => [100, 100]
  end

  def extension_white_list
    %w(jpg jpeg gif png)
  end
end

EDIT: I have narrowed the issue down to something with modifying the image after upload. If I simplify the code even farther to remove the creation of the :thumb size then everything works. Thoughts?

Upvotes: 3

Views: 2397

Answers (3)

UnSandpiper
UnSandpiper

Reputation: 546

Not enough reputation to comment theflyingbrush's answer, but he is absolutely right. I had the same issue before noticing that I was actually missing imagemagick all together.

So on Debian/Ubuntu this will do the trick (or 'magick'):

apt-get install imagemagick

On operating systems with yum as packet manager (CentOS/RedHat) you'd be using:

yum install ImageMagick

Upvotes: 6

theflyingbrush
theflyingbrush

Reputation: 248

Have you explicitly installed ImageMagick?

I had the same error when using MiniMagick without installing ImageMagick. As I understand it MiniMagick defers operations to the mogrify command, so if you can't call mogrify on the command line, MiniMagick probably can't either.

A *nix buff would be able to answer this with more confidence, but I think libmagickwand-dev supports the installation of graphics libraries, but doesn't actually install any itself.

Upvotes: 0

Michael
Michael

Reputation: 1

You are missing storage location. Try adding this under storage :file

  def store_dir
    "uploads/logo/#{model.id}"
  end

Upvotes: 0

Related Questions