140

I'm trying to get RMagick setup on Ubuntu 10.04. Looked here but had no joy. I even compiled and installed ImageMagick from source, but the instructions here still didn't help me when I try to install RMagick using RubyGems. I got this error:

carcher@carcher-laptop:~/Code/temp/RMagick-2.13.1$ sudo gem install rmagick
Building native extensions.  This could take a while...
ERROR:  Error installing rmagick:
 ERROR: Failed to build gem native extension.

/usr/bin/ruby1.8 extconf.rb
extconf.rb:1:in `require': no such file to load -- mkmf (LoadError)
 from extconf.rb:1


Gem files will remain installed in /usr/lib/ruby/gems/1.8/gems/rmagick-2.13.1 for inspection.
Results logged to /usr/lib/ruby/gems/1.8/gems/rmagick-2.13.1/ext/RMagick/gem_make.out
carcher@carcher-laptop:~/Code/temp/RMagick-2.13.1$ 

What does it all mean? :) I'm new to Ruby and RubyGems so please be gentle. My setup is as follows:

Ruby: 1.8.7
RubyGems: 1.3.7

I'm pretty much out of ideas (and tired too!). I tired to compile RMagick from source using the link above but it failed as there was no ./configure script :(

Any and all help appreciated!

Promise Preston
  • 24,334
  • 12
  • 145
  • 143
Ciaran Archer
  • 12,316
  • 9
  • 38
  • 55
  • Most of these answers are different than the official docs, You should install `imagemagick`, `libmagickcore-dev`, and `libmagickwand-dev`: https://github.com/rmagick/rmagick/wiki/Installing-on-Ubuntu – Robin Clowers Oct 16 '14 at 00:36

15 Answers15

274

Install the packages imagemagick and libmagickwand-dev (or libmagick9-dev). You should then be able to install the Rmagick Gem.

sudo apt-get install imagemagick libmagickwand-dev

If not, you are missing ruby related development packages like build-essential and ruby1.8-dev. If that's the case, a generic "ubuntu install ruby 1.8" query in google should sort you out.

Sergio Tulentsev
  • 226,338
  • 43
  • 373
  • 367
gcahill
  • 3,155
  • 1
  • 17
  • 11
  • 1
    This (imagemagick and libmagickwand-dev) appears to have worked and I can see RMagick 2.13.1 as one of my listed gems! – Ciaran Archer Sep 14 '10 at 17:25
  • 3
    As I commented below, worked fine for me just now with just libmagickwand-dev and I didn't need any additional packages. At least for Magick::ImageList.from_blob, Magick::ImageList.resize, and Magick::ImageList.write. Not sure about other methods. – umassthrower Nov 26 '12 at 06:04
  • This is by the far the quickest answer! AMAZING! – Tomer Jun 10 '15 at 12:27
  • 1
    On Ubuntu 14.04 LTS you have to first install libmagickcore-dev and then libmagickwand-dev, otherwise apt-get will refuse to install the wand dev package. (You should be able to install them in one command line, as follows: `sudo apt-get install imagemagick libmagickcore-dev libmagickwand-dev`) (source: http://askubuntu.com/questions/112548/rmagick-install-problem/112551#112551) – Dalibor Filus Oct 04 '15 at 14:28
  • In my case - after a lot of trying, apt-get told me that libmagickwand-dev requires libmagickcore-dev but is not going to be installed. I run `sudo apt-get install libmagickcore-dev` before magigwand and it helped :) – Greg Mar 09 '16 at 10:39
  • On Ubuntu 16.04 LTS, when i run the command sudo apt-get install imagemagick libmagickwand-dev. Its giving error The following packages have unmet dependencies: libmagickwand-dev : Depends: libmagickwand-6.q16-dev but it is not going to be installed – Create Explorer Jun 15 '18 at 10:44
63

You don't need a lot of the other junk in these answers, just:

sudo apt-get install libmagickwand-dev
Daniel X Moore
  • 14,637
  • 17
  • 80
  • 92
  • 4
    I can confirm this worked on Ubuntu 14.04. As a side note, you also need the packages `ruby-dev` and `make`...which may already be there on a typical system, but weren't there on the docker image. – Dan Allen Jul 30 '14 at 06:32
  • You also need the `imagemagick` package: https://github.com/rmagick/rmagick/wiki/Installing-on-Ubuntu – Robin Clowers Oct 16 '14 at 00:32
  • After searching for about an hour, Dan Allen's comment ^ (about installing `make` and `ruby-dev`) finally fixed it. Thanks! – Kabir Sarin Dec 23 '14 at 16:11
  • Do not forget to do: `sudo apt-get update` before this. – ZombieBsAs Dec 08 '16 at 20:13
29

On Ubuntu 12.04 libmagick9-dev is gone. graphicsmagick-libmagick-dev-compat should be used instead.

apt-get install graphicsmagick-libmagick-dev-compat
Michał Szajbe
  • 8,830
  • 3
  • 33
  • 39
25

On Ubuntu 15.04, what solved it for me was to remove all previous *magick installations, reinstall required packages and then symlink the config file:

sudo apt-get purge graphicsmagick graphicsmagick-dbg imagemagick-common imagemagick imagemagick-6.q16 libmagickcore-6-headers libmagickwand-dev graphicsmagick-libmagick-dev-compat
sudo apt-get autoremove
sudo apt-get install imagemagick libmagickwand-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16/Magick-config /usr/bin/Magick-config
gem install rmagick
Mike
  • 987
  • 11
  • 13
  • 1
    Thank you so much. I think all the other Ubuntu answers are outdated. – bjmc Jun 29 '15 at 04:08
  • 6
    Thanks. That worked for me after upgrading 14.04 to 16.04. – nroose Apr 23 '16 at 23:02
  • 1
    This solution not working in Ubuntu 16.04 LTS, when run the command sudo apt-get install imagemagick libmagickwand-dev, giving error "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" – Create Explorer Jun 15 '18 at 11:38
16

In Ubuntu 14.04


Below code is worked for me

sudo apt-get install imagemagick libmagickcore-dev libmagickwand-dev

Then,

gem install rmagick
yellowsir
  • 741
  • 1
  • 9
  • 27
bapu
  • 661
  • 6
  • 7
12

On Ubuntu 12.0.4.2 sudo apt-get install libmagickwand-dev libmagickcore-dev libmagickcore4-extra libgraphviz-dev libgvc5 worked for me.

graphicsmagick-libmagick-dev-compat installed but didn't include the header files so rmagick wouldn't compile.

Please note, you need to remove graphicsmagick-libmagick-dev-compat before running the command above.

Larry
  • 171
  • 1
  • 3
7

this worked for me...

sudo apt-get install graphicsmagick-libmagick-dev-compat libmagickwand-dev 

gem install rmagick

...

Building native extensions.  This could take a while...
Successfully installed rmagick-2.13.1
1 gem installed

(ubuntu 12.0.4 64bit)

John Griffiths
  • 585
  • 7
  • 15
3

In Ubuntu 13.10

This code worked for me

sudo apt-get install graphicsmagick-libmagick-dev-compat libmagickwand-dev

gem install rmagick

Deepak Lamichhane
  • 19,076
  • 4
  • 30
  • 42
3

You got message extconf.rb:1:in 'require': no such file to load -- mkmf (LoadError) because package ruby1.8-dev isn't installed. Install it (sudo apt-get install ruby1.8-dev) and try again.

antage
  • 1,100
  • 7
  • 11
2

To get bundle to stop failing on ubuntu 12.04.

apt-get install graphicsmagick-libmagick-dev-compat libmagickwand-dev

This is my gemfile

gem 'rmagick' 
gem 'mini_magick' 
jmontross
  • 3,533
  • 1
  • 21
  • 17
2

On Ubuntu, you can run:

sudo apt-get install libmagickwand-dev

On Centos, you can run:

sudo yum install gcc ImageMagick-devel make which

Then install

gem install rmagick
Mahesh Bablu
  • 131
  • 1
  • 7
0

If you want to try installing the native deb package instead of the gem, be aware that the librmagick-ruby was broken on Ubuntu 10.04 until just very recently:

https://bugs.launchpad.net/ubuntu/+source/librmagick-ruby/+bug/518122

See comment #17 in particular. I believe this has already been fixed so now apt-get install librmagick-ruby might "just work". Otherwise here's how to build it yourself from source

$ cd /usr/src
$ sudo apt-get build-dep librmagick-ruby
$ sudo apt-get source librmagick-ruby
$ cd librmagick-ruby-2.11.1
$ sudo dch -i
(add changelog entry)
$ sudo dpkg-buildpackage
$ cd ..
$ sudo dpkg -i librmagick-ruby*.deb
Peter Lyons
  • 142,938
  • 30
  • 279
  • 274
0

In ubuntu 16.04.3:

This i worked:

sudo apt install imagemagick imagemagick-6.q16

It means this installed imagemagick then you can run RMagick.

  • 1
    This solution is not working form in ubuntu 16.04.3, showing error "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." – Create Explorer Jun 15 '18 at 11:40
0

If you are using Linux then simply run these commands.

 sudo apt-get install imagemagick libmagickwand-dev

and then

 bundle install

Hope this will resolve your issue.

And if you are using mac then simply run following commands

First of all unlink your installed imagemagick which was not properly installed in latest mac high sierra by using.

 brew unlink imagemagick

then install latest imagemagic6 using below command

 brew install imagemagick@6 && brew link imagemagick@6 --force

Then install gem rmagick using below command

 gem install rmagick 

 bundle install

It will work perfectly fine.

Ali Hassan Mirza
  • 552
  • 11
  • 23
0

Follow below 3 steps proven on UBUNTU 16.04

sudo apt-get install build-essential imagemagick libmagickwand-dev

#In .bashrc or .bash_profile add below code. Just check the ImageMagick dir name.
export PATH="/usr/lib/x86_64-linux-gnu/ImageMagick-6.8.9/bin-Q16:$PATH"
gem install rmagic #Install Gem
Hrishi
  • 446
  • 3
  • 10