Skip to content

Commit

Permalink
Raise MiniMagick::Error if ImageMagick is missing delegates
Browse files Browse the repository at this point in the history
Fixes #2732

Starting in Alpine Linux 3.19, installing the `imagemagick` package no
longer includes support for JPG, SVG, and other image formats.[1]

This means upgrading Alpine linux on a server can cause Carrierwave to
start failing with CarrierWave::ProcessingError when uploading images.

The root cause isn't obvious from this error.

However when ImageMagick is not installed, Carrierwave raises
MiniMagick::Error instead of CarrierWave::ProcessingError, and includes
the detailed error message.

This fix also raises MiniMagick::Error if ImageMagick is installed but
is missing the delegates required for the image format being
manipulated. This will make it easier to debug when uploads are failing.

[1] https://maxsmolens.org/posts/imagemagick-packaging-change-on-alpine-linux/
  • Loading branch information
danwilliams-fl committed Jan 8, 2025
1 parent f062091 commit 01ebc84
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/carrierwave/processing/mini_magick.rb
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ def manipulate!

::MiniMagick::Image.new(current_path).identify
rescue ::MiniMagick::Error, ::MiniMagick::Invalid => e
raise e if e.message =~ /(You must have .+ installed|is not installed|executable not found)/
raise e if e.message =~ /(You must have .+ installed|is not installed|executable not found|delegate failed)/
message = I18n.translate(:"errors.messages.processing_error")
raise CarrierWave::ProcessingError, message
ensure
Expand Down

0 comments on commit 01ebc84

Please sign in to comment.