From 91fbd5b422625bdf30b9ce6655378db7f804e510 Mon Sep 17 00:00:00 2001 From: Michael Stanclift Date: Mon, 29 Jul 2024 09:32:29 -0500 Subject: [PATCH] Adjust magick version detection in admin panel (#30845) --- .../metrics/dimension/software_versions_dimension.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/lib/admin/metrics/dimension/software_versions_dimension.rb b/app/lib/admin/metrics/dimension/software_versions_dimension.rb index 71d6c63fb..84ffc41d7 100644 --- a/app/lib/admin/metrics/dimension/software_versions_dimension.rb +++ b/app/lib/admin/metrics/dimension/software_versions_dimension.rb @@ -85,7 +85,14 @@ class Admin::Metrics::Dimension::SoftwareVersionsDimension < Admin::Metrics::Dim def imagemagick_version return if Rails.configuration.x.use_vips - version = `convert -version`.match(/Version: ImageMagick ([\d\.]+)/)[1] + imagemagick_binary = Paperclip.options[:is_windows] ? 'magick convert' : 'convert' + + version_output = Terrapin::CommandLine.new(imagemagick_binary, '-version').run + version_match = version_output.match(/Version: ImageMagick (\S+)/)[1].strip + + return nil unless version_match + + version = version_match { key: 'imagemagick', @@ -93,7 +100,7 @@ class Admin::Metrics::Dimension::SoftwareVersionsDimension < Admin::Metrics::Dim value: version, human_value: version, } - rescue Errno::ENOENT + rescue Terrapin::CommandNotFoundError, Terrapin::ExitStatusError, Paperclip::Errors::CommandNotFoundError, Paperclip::Errors::CommandFailedError nil end