I just faced this issue on Ubuntu 20.04, what fixed the it for me was install imagemagick through linuxbrew:
brew install imagemagick@6 && brew link imagemagick@6 --force
Then just follow brew documentation:
To have imagemagick@6 first in your PATH run:
echo 'export PATH="/home/linuxbrew/.linuxbrew/opt/imagemagick@6/bin:$PATH"' >> /home/visiond/.bash_profile
For compilers to find imagemagick@6 run:
export LDFLAGS="-L/home/linuxbrew/.linuxbrew/opt/imagemagick@6/lib"
export CPPFLAGS="-I/home/linuxbrew/.linuxbrew/opt/imagemagick@6/include"
For pkg-config to find imagemagick@6 run:
export PKG_CONFIG_PATH="/home/linuxbrew/.linuxbrew/opt/imagemagick@6/lib/pkgconfig"
Then try to install rmagick again
gem install rmagick -v '2.16.0'
if it complains about missing pkg-config run
brew reinstall pkg-config
Now try installing rmagick again, everything should work.
If you're using WSL, it could still fail, changing
gem 'rmagick', '~> 2.16.0'
to
gem 'rmagick', '~> 2.15', '>= 2.15.4', :platforms => :ruby
Should fix the issue completely.
Update
Sometimes the brew option will give you a weird error that says something like
Rmagick was configured with <some-imagemagick-version> but <other-imagemagick-version> is in use
This is normally an issue related to linuxbrew, what I did to fix it was
rollback everything explained up there ^^
brew uninstall imagemagick@6
brew uninstall pkg-config
then remove all these lines from your bashrc
export PATH="/home/linuxbrew/.linuxbrew/opt/imagemagick@6/bin:$PATH"
export LDFLAGS="-L/home/linuxbrew/.linuxbrew/opt/imagemagick@6/lib"
export CPPFLAGS="-I/home/linuxbrew/.linuxbrew/opt/imagemagick@6/include"
export PKG_CONFIG_PATH="/home/linuxbrew/.linuxbrew/opt/imagemagick@6/lib/pkgconfig"
Refresh your terminal with latest changes
source ~/.bashrc
Make sure you don't have any imagemagick installed by running:
convert -version
If you get something like
Version: ImageMagick 6.9.10-23 Q16 x86_64 20190101 https://imagemagick.org
Copyright: © 1999-2019 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib djvu fftw fontconfig freetype jbig jng jpeg lcms lqr ltdl lzma openexr pangocairo png tiff webp wmf x xml zlib
it means you still have imagemagick in your system, this could be due to various reasons:
- You installed imagemagick from source
- You installed imagemagick through apt
If 1
Remove imagemagick by going to the folder where you ran make install
and just run make uninstall
, this should remove the package completely, then try convert -version
again
If 2
Check the version of the package, if you're trying to install rmagick < v3, then you'll need imagemagick 6, if not, any imagimagick works.
Assuming you have a new version of imagemagick (IE: 7) and you need an older version for your rmagick, just do a
sudo apt remove --purge imagemagick
Now that we have our system clean, we can install imagemagick again
sudo apt-get install imagemagick-6.q16
try installing rmagick again
gem install rmagick -v '2.16.0
if it complains about MagickCore, it means you need to install libmagickwand-dev
, to do so:
sudo apt-get install libmagickwand-dev
now try again, everything should work :)