Defect #42145
openMiniMagick (> 5) removed cli_path, result crash when supplied imagemagick_convert_command
0%
Description
Summary¶
MiniMagick (> 5) removed cli_path, result crash when supplied imagemagick_convert_command
- condition:
configuration.yml have
- version : 6.0.0 ~ 6.0.2 docker image
- configuration supplied:
imagemagick_convert_command
- additional information
- db : postgres:14-bookworm (14.15 (Debian 14.15-1.pgdg120+1))
- ruby version: ruby 3.3.7 (2025-01-15 revision be31f993d7) [x86_64-linux]
- redmine version: 6.0.2-bookworm
- plugin : none
Symptom¶
v6.0.x docker image, when pressing PNG button in gantt chart, application crash
log:
redmine-orig | [3369ac1d-8d3b-49ca-b5d8-cc6f9c5ac01c] NoMethodError (undefined method `cli_path=' for module MiniMagick): redmine-orig | [3369ac1d-8d3b-49ca-b5d8-cc6f9c5ac01c] redmine-orig | [3369ac1d-8d3b-49ca-b5d8-cc6f9c5ac01c] lib/redmine/helpers/gantt.rb:399:in `to_image' redmine-orig | [3369ac1d-8d3b-49ca-b5d8-cc6f9c5ac01c] app/controllers/gantts_controller.rb:46:in `block (2 levels) in show' redmine-orig | [3369ac1d-8d3b-49ca-b5d8-cc6f9c5ac01c] app/controllers/gantts_controller.rb:42:in `show' redmine-orig | [3369ac1d-8d3b-49ca-b5d8-cc6f9c5ac01c] lib/redmine/sudo_mode.rb:78:in `sudo_mode'
cause estimated¶
- mini_magick 4.12.0 has both
cli_path
andcli_prefix
- mini_magick 5.0.1 has removed
cli_path
Updated by Marius BĂLTEANU 15 days ago
- Target version set to 5.1.8
Indeed, it seems that MiniMagick >= 5.0 removed the cli_path
configuration option and I don't see an alternative flag to define the custom path. A quick way to fix this is:
diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb
index 43e0986c6..a17cae2a8 100644
--- a/lib/redmine/helpers/gantt.rb
+++ b/lib/redmine/helpers/gantt.rb
@@ -396,7 +396,13 @@ module Redmine
Redmine::Configuration['rmagick_font_path'].presence
img = MiniMagick::Image.create(".#{format}")
if Redmine::Configuration['imagemagick_convert_command'].present?
- MiniMagick.cli_path = File.dirname(Redmine::Configuration['imagemagick_convert_command'])
+ if MiniMagick.respond_to?(:cli_path)
+ MiniMagick.cli_path = File.dirname(Redmine::Configuration['imagemagick_convert_command'])
+ else
+ Rails.logger.warn(
+ 'imagemagick_convert_command configuration option is ignored because MiniMagick have removed the option to define a custom path for the binary. Please ensure convert bin is available in your path.'
+ )
+ end
end
MiniMagick.convert do |gc|
gc.size('%dx%d' % [subject_width + g_width + 1, height])
Looking at the versions in Gemfile, the above fix should be merged only for 5.1.8 where MiniMagick is pinned to ~> 4.12.0
. In 6.*, we can completely remove this configuration flag because MiniMagick is pinned at version 5.
Updated by Marius BĂLTEANU 15 days ago
Jonathan Cormier wrote in #note-2:
Is there a fix or work around for this?
The easiest way to fix this without applying the above code is to remove/comment the configuration option (imagemagick_convert_command
) from your configuration.yml
file. Please do not forget to restart your Redmine installation after this change.
Updated by Jonathan Cormier 15 days ago
Marius BĂLTEANU wrote in #note-4:
Jonathan Cormier wrote in #note-2:
Is there a fix or work around for this?
The easiest way to fix this without applying the above code is to remove/comment the configuration option (
imagemagick_convert_command
) from yourconfiguration.yml
file. Please do not forget to restart your Redmine installation after this change.
Thanks, if I'm understanding correctly. Without the imagemagick_convert_command
option specified, redmine will check for it in the PATH instead?
Updated by Marius BĂLTEANU 15 days ago
Jonathan Cormier wrote in #note-5:
[..]
Thanks, if I'm understanding correctly. Without the
imagemagick_convert_command
option specified, redmine will check for it in the PATH instead?
Yes.
Updated by Marius BĂLTEANU 14 days ago
Marius BĂLTEANU wrote in #note-3:
Indeed, it seems that MiniMagick >= 5.0 removed the
cli_path
configuration option and I don't see an alternative flag to define the custom path. A quick way to fix this is:[...]
Looking at the versions in Gemfile, the above fix should be merged only for 5.1.8 where MiniMagick is pinned to
~> 4.12.0
. In 6.*, we can completely remove this configuration flag because MiniMagick is pinned at version 5.
imagemagick_convert_command
is also utilised in Redmine::Thumbnail
module where we generate the thumbnail by passing to the shell the convert command. In this case, the configuration option will also work on MiniMagick 5. I think the safest way to fix this in maintained versions is the workaround from the quoted note.
On long term, I think it's better to understand if it's possible to replace the convert command executed through the shell with the internal API to generate the thumbnail as we do generate the PNG in Gantt.