4

I 'm on Ubuntu 16.04 , in gemfile I have gem "rmagick" and when I bundle it says

An error occurred while installing rmagick (2.16.0), and Bundler cannot
continue.
Make sure that `gem install rmagick -v '2.16.0'` succeeds before bundling.

as suggested above when I try gem install rmagick -v '2.16.0' it says

Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
    ERROR: Failed to build gem native extension.

    current directory: /home/faisal/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rmagick-2.16.0/ext/RMagick
/home/faisal/.rbenv/versions/2.3.1/bin/ruby -r ./siteconf20160926-26223-16sn0dg.rb extconf.rb
checking for gcc... yes
checking for Magick-config... no
checking for pkg-config... yes
Package MagickCore was not found in the pkg-config search path.
Perhaps you should add the directory containing `MagickCore.pc'
to the PKG_CONFIG_PATH environment variable
No package 'MagickCore' found
checking for outdated ImageMagick version (<= 6.4.9)... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/faisal/.rbenv/versions/2.3.1/bin/$(RUBY_BASE_NAME)

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/faisal/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/rmagick-2.16.0/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/faisal/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/rmagick-2.16.0 for inspection.
Results logged to /home/faisal/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/rmagick-2.16.0/gem_make.out

I have tried dozen of different ways provided in different questions but none of the work.

Muhammad Faisal Iqbal
  • 1,796
  • 2
  • 20
  • 43
  • Possible duplicate of [Error installing rmagick: ERROR: Failed to build gem native extension](http://stackoverflow.com/questions/19274293/error-installing-rmagick-error-failed-to-build-gem-native-extension) – Deepak Mahakale Sep 26 '16 at 09:48
  • @Deepak I tried all solution provided in DUPLICATE QUESTION but same issue persist – Muhammad Faisal Iqbal Sep 26 '16 at 10:11

13 Answers13

29

In MacOS, you can do this:

brew unlink imagemagick
brew install imagemagick@6 && brew link imagemagick@6 --force
Khanh Pham
  • 2,848
  • 2
  • 28
  • 36
11

Try this, You need to run the following commands for ubuntu

sudo apt-get install libmagick++-dev
sudo apt-get install imagemagick

Then try to install

gem install rmagick
Navin
  • 914
  • 8
  • 16
  • while installing libmagick++-dev it says "The following packages have unmet dependencies: libmagick++-dev : Depends: libmagick++-6.q16-dev but it is not going to be installed E: Unable to correct problems, you have held broken packages. " – Muhammad Faisal Iqbal Sep 26 '16 at 09:49
  • use sudo apt-get clean to clear cache and sudo apt-get autoremove, and use sudo apt-get update ,then try to install with following steps as we mention above – vipin Sep 26 '16 at 09:59
  • I did "clean, autoromove and update" and followed these steps but same issue – Muhammad Faisal Iqbal Sep 26 '16 at 11:04
2

the only thing that worked for me was

brew unlink pkgconfig
bundle install
brew link pkgconfig
davideghz
  • 3,596
  • 5
  • 26
  • 50
2

On Ubuntu you should first install this

sudo apt-get install libmagickwand-dev

Then install gem install rmagick

Mahesh Bablu
  • 131
  • 1
  • 7
1

On mac/osx, make sure you brew install imagemagick@6 (NOT 7)

natee.biz
  • 89
  • 1
  • 6
1

On Mac High Sierra - 10.13.4 - https://www.imagemagick.org/script/download.php

sudo port install ImageMagick   
sudo gem install rmagick
Jean-François Fabre
  • 137,073
  • 23
  • 153
  • 219
1

On Fedora (when I installed Redmine) that worked for me:

sudo dnf install ImageMagick-devel
bundle install
BorZ
  • 51
  • 3
0

You are missing dependencies from Imagemagick which are required for rmagick gem to work

    sudo apt-get update
    sudo apt-get install imagemagick

Once done, bundle should execute successfully and install the gems.

Bijendra
  • 9,467
  • 8
  • 39
  • 66
  • Try installing sudo apt-get install libmagickwand-dev , then restart your terminal – Bijendra Sep 26 '16 at 10:31
  • on trying this it says "The following packages have unmet dependencies: libmagickwand-dev : Depends: libmagickwand-6.q16-dev but it is not going to be installed E: Unable to correct problems, you have held broken packages." – Muhammad Faisal Iqbal Sep 26 '16 at 10:51
0

try this

$ sudo apt-get install libmagick++-dev

and then

bundle install

and install Imagemagick

$ sudo apt-get install imagemagick

Then, install the rmagick gem :

$ sudo gem install rmagick
vipin
  • 2,374
  • 1
  • 19
  • 36
  • at first commnad it says "The following packages have unmet dependencies: libmagick++-dev : Depends: libmagick++-6.q16-dev but it is not going to be installed " – Muhammad Faisal Iqbal Sep 26 '16 at 09:56
  • Add PPA: sudo add-apt-repository ppa:ricotz/testing Then update package list: sudo apt-get update then use sudo apt-get install libmagickwand-dev – vipin Sep 26 '16 at 11:15
  • @vipin gems should not be installed with sudo privileges, try to install gems at a project level to avoid screwing up your system in long run. – Bijendra Sep 26 '16 at 13:22
  • Try to refer this link. though not sure if it's the same issue. http://askubuntu.com/questions/140246/how-do-i-resolve-unmet-dependencies-after-adding-a-ppa – Bijendra Sep 26 '16 at 13:25
0

Type in the following commands on the console -

sudo apt-get install libmagick9-dev
sudo apt-get install graphicsmagick-libmagick-dev-compat
sudo apt-get install libmagickwand-dev
sudo apt-get install libmagickcore-dev
sudo apt-get install libmagick++-dev

Let me know if it solves the issue

Caffeine Coder
  • 1,869
  • 1
  • 17
  • 35
  • at the very first command it says "Reading package lists... Done Building dependency tree Reading state information... Done Package libmagick9-dev is not available, but is referred to by another package. This may mean that the package is missing, has been obsoleted, or is only available from another source However the following packages replace it: graphicsmagick-libmagick-dev-compat E: Package 'libmagick9-dev' has no installation candidate" – Muhammad Faisal Iqbal Sep 26 '16 at 11:20
0

On Mac OSX 10.12.3, I have also tried many methods to install rmagick and finally I solved my problem.

brew doctor says ............

Warning: You have unlinked kegs in your Cellar Leaving kegs unlinked can lead to build-trouble and cause brews that depend on those kegs to fail to run properly once built. Run brew link on these: imagemagick

Warning: Some keg-only formula are linked into the Cellar. Linking a keg-only formula, such as gettext, into the cellar with brew link <formula> will cause other formulae to detect them during the ./configure step. This may cause problems when compiling those other formulae.

Binaries provided by keg-only formulae may override system binaries with other strange results.

You may wish to brew unlink these brews: imagemagick@6

I did

>brew unlink imagemagick@6
Unlinking /usr/local/Cellar/imagemagick@6/6.9.7-9... 60 symlinks removed
>brew link imagemagick
Linking /usr/local/Cellar/imagemagick/6.9.7-3... 75 symlinks created

then

 >gem install rmagick

works for me

My advice: Try to install correct version of imagemagick and listen brew doctors advice.

yalcin
  • 31
  • 2
0

A little late to the game but the following worked for me on Ubuntu 16.04:

Probably overkill a bit but first you'll want to enable all deb-src lines in your sources.list:

sudo vi /etc/apt/sources.list

Then do an apt update:

sudo apt update

Now you should be able to install all the required packages:

sudo apt install libfreetype6-dev libfontconfig1-dev libpng-dev libwmf-dev libpango1.0-dev librsvg2-dev libmagickcore-dev libmagickwand-dev imagemagick

(personally I installed libmagickcore-dev, libmagickwand-dev, imagemagick one at a time during my debugging but you should be able to install them all at once)

Hope this helps

innou
  • 1
0

For Centos 6 for the and above

yum install ImageMagick-devel

bundle install