carrierwaveuploader/carrierwave · error · CarrierWave::ProcessingError
errors.messages.processing_error
Error message
errors.messages.processing_error
What it means
Raised as CarrierWave::ProcessingError by CarrierWave::RMagick#manipulate! when RMagick raises ::Magick::ImageMagickError while loading or writing frames — for example a corrupt image, an unsupported format, or a write to a format string like "png:/path". Unlike the MiniMagick variant, every ImageMagickError becomes the generic processing error; there is no re-raise for install problems.
Source
Thrown at lib/carrierwave/processing/rmagick.rb:401
frame = yield(*[frame, index, options].take(block.arity)) if block_given?
frames << frame if frame
end
frames.append(true) if block_given?
write_block = create_info_block(options[:write])
if options[:format] || @format
frames.write("#{options[:format] || @format}:#{current_path}", &write_block)
move_to = current_path.chomp(File.extname(current_path)) + ".#{options[:format] || @format}"
file.content_type = Marcel::Magic.by_path(move_to).try(:type)
file.move_to(move_to, permissions, directory_permissions)
else
frames.write(current_path, &write_block)
end
destroy_image(frames)
rescue ::Magick::ImageMagickError
raise CarrierWave::ProcessingError, I18n.translate(:"errors.messages.processing_error")
end
private
def create_info_block(options)
return nil unless options
proc do |img|
options.each do |k, v|
if v.is_a?(String) && (matches = v.match(/^["'](.+)["']/))
CarrierWave.deprecator.warn "Passing quoted strings like #{v} to #manipulate! is deprecated, pass them without quoting."
v = matches[1]
end
img.public_send(:"#{k}=", v)
end
end
end
def destroy_image(image)View on GitHub (pinned to b5f0abe10e)
Solutions
- Validate the file is a readable image before processing (Marcel sniff or Magick::ImageList.read probe in a cache callback) and reject early
- Rescue CarrierWave::ProcessingError where uploads are handled and return a validation error
- Reinstall/recompile the rmagick gem against the installed ImageMagick (gem pristine rmagick) if errors happen for every image
- Migrate from the deprecated RMagick engine to CarrierWave::MiniMagick or CarrierWave::Vips, which are maintained
Example fix
# before
class PhotoUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
process resize_to_limit: [800, 800] # corrupt file -> ProcessingError
end
# after
class PhotoUploader < CarrierWave::Uploader::Base
include CarrierWave::RMagick
process resize_to_limit: [800, 800]
before_cache :verify_image!
def verify_image!(file)
Magick::ImageList.new(file.path).first
rescue Magick::ImageMagickError
raise CarrierWave::ProcessingError, :invalid_image
end
end Defensive patterns
Strategy: try-catch
Validate before calling
def valid_rmagick_image?(path) list = Magick::ImageList.new(path) !list.empty? && list.columns > 0 rescue Magick::ImageMagickError false end
Try / catch
begin uploader.cache!(uploaded) rescue CarrierWave::ProcessingError uploader.errors.add(:base, :processing_failed) end
Prevention
- Probe files with Magick::ImageList.new(path) in a before_cache callback and reject on ImageMagickError
- Recompile the rmagick gem after any ImageMagick system upgrade (gem pristine rmagick)
- Plan migration off RMagick to MiniMagick/Vips — RMagick is deprecated and error surfaces are worse
When it happens
Trigger: An uploader including CarrierWave::RMagick with process blocks (or a custom manipulate! block calling frames operations) where Magick::ImageList.read/read_inline fails on the input or frames.write fails — corrupt bytes, wrong extension, or an output format the ImageMagick build cannot encode.
Common situations: RMagick/ImageMagick version mismatches (RMagick compiled against ImageMagick 6 then the system upgrades to 7), memory-exhausting large images surfacing as ImageMagickError, and user-uploaded files that are not actually images.
Related errors
- errors.messages.processing_error
- errors.messages.processing_error
- errors.messages.content_type_allowlist_error
- errors.messages.content_type_denylist_error
- errors.messages.min_width_error
AI-assisted analysis of carrierwaveuploader/carrierwave@b5f0abe10e (2026-08-21).
Data as JSON: /api/errors/551848df3cccfc74.
Report an issue: GitHub.