Project

General

Profile

Actions

Defect #42145

open

MiniMagick (> 5) removed cli_path, result crash when supplied imagemagick_convert_command

Added by Inseo Park 2 months ago. Updated 14 days ago.

Status:
Confirmed
Priority:
Normal
Assignee:
-
Category:
Gantt
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

Summary

MiniMagick (> 5) removed cli_path, result crash when supplied imagemagick_convert_command

  • condition:
  • version : 6.0.0 ~ 6.0.2 docker image
  • configuration supplied:
configuration.yml have 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 and cli_prefix
  • mini_magick 5.0.1 has removed cli_path
reference sites:
Actions #1

Updated by Go MAEDA 2 months ago

  • Status changed from New to Confirmed
Actions #2

Updated by Jonathan Cormier 18 days ago

Is there a fix or work around for this?

Actions #3

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.

Actions #4

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.

Actions #5

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 your configuration.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?

Actions #6

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.

Actions #7

Updated by Jonathan Cormier 15 days ago

Great, thanks

Actions #8

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.

Actions

Also available in: Atom PDF