Fix: integrated imagemagick into github workflow and resolved the cou… #6116
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does
This pull request resolves a compatibility issue with ImageMagick in the CI workflow, which caused the error: Paperclip::Errors::CommandNotFoundError: Could not run the 'identify' command. Please install ImageMagick.
Issue:
kt-paperclip expected separate binaries for identify and convert, but recent versions of ImageMagick consolidate these tools into the magick command. Additionally, the location of the magick binary was not where Paperclip expected.
Changes Made
To address the issue and ensure that kt-paperclip works with the latest version of ImageMagick, I implemented the following changes:
Installed ImageMagick: I installed the required version of ImageMagick on the system to ensure that Paperclip has access to the necessary tools.
Created Symlinks for identify and convert:
Since Paperclip calls identify and convert, I created symlinks for these commands that point to the magick binary. This allows Paperclip to use magick in place of the older separate identify and convert binaries
for cmd in identify convert; do if ! [ -x "$(command -v $cmd)" ]; then sudo ln -s $(which magick) /usr/bin/$cmd fi done
Cached ImageMagick Binary:
To speed up subsequent builds and avoid re-downloading ImageMagick each time, I added caching for the ImageMagick binary:
- name: Cache Latest ImageMagick uses: actions/cache@v3 with: path: /home/runner/bin/magick key: ${{ runner.os }}-imagemagick-latest restore-keys: | ${{ runner.os }}-imagemagick-latest
Updated Path for ImageMagick:
To ensure that the system recognizes the location of ImageMagick binaries, I updated the system path to include the directory where magick is located (/home/runner/bin).
- name: Update PATH for ImageMagick run: echo "/home/runner/bin" >> $GITHUB_PATH
I explicitly configured Paperclip to look for ImageMagick commands in /usr/bin, where the symlinks for identify and convert are located.
Paperclip.options[:command_path] = "/usr/bin"
These changes ensure Paperclip functions correctly with the latest ImageMagick version, using the consolidated magick binary, and improve build efficiency by caching the binary