title: Ubuntu - cannot install RMagick
body: <p>How to install the RMagick gem to Ubuntu? I found a few threads here on SO, some of there directly pointed out to the installation on Ubuntu systems, but none of them is working for me.</p>
  
  <p>Here is the output that I got if I run <strong>sudo gem install rmagick</strong></p>
  
  <pre><code>Building native extensions.  This could take a while...
  ERROR:  Error installing rmagick:
      ERROR: Failed to build gem native extension.
  
          /opt/bitnami/ruby/bin/ruby extconf.rb
  checking for Ruby version &gt;= 1.8.5... yes
  checking for gcc... yes
  checking for Magick-config... yes
  
  Warning: Found more than one ImageMagick installation. This could cause problems at runtime.
           /opt/bitnami/common/bin/Magick-config reports version 6.7.5 Q16 is installed in /opt/bitnami/common
           /usr/bin/Magick-config reports version 6.6.9 Q16 is installed in /usr
  Using 6.7.5 Q16 from /opt/bitnami/common.
  
  checking for ImageMagick version &gt;= 6.4.9... yes
  checking for HDRI disabled version of ImageMagick... 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
  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
  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
  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 stdint.h... yes
  checking for sys/types.h... yes
  checking for wand/MagickWand.h... no
  
  Can't install RMagick 2.13.2. Can't find MagickWand.h.
  *** 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=/opt/bitnami/ruby/bin/ruby
  
  
  Gem files will remain installed in /opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rmagick-2.13.2 for inspection.
  Results logged to /opt/bitnami/ruby/lib/ruby/gems/1.9.1/gems/rmagick-2.13.2/ext/RMagick/gem_make.out
  </code></pre>
  
  <p>It's on Amazon EC2 servers.
  If I try to run just <strong>gem install rmagick</strong>, I get</p>
  
  <pre><code>ERROR:  While executing gem ... (Gem::FilePermissionError)
      You don't have write permissions into the /opt/bitnami/ruby/lib/ruby/gems/1.9.1 directory.
  </code></pre>
  
  <p>Could you help me, please, how to fix this issue?</p>
  
  <p>Thank you very much</p>
  
  <p><strong>EDIT:</strong> What I've tried:</p>
  
  <ol>
  <li><p>sudo apt-get install libmagickwand-dev</p>
  
  <pre><code>Reading package lists... Done
  Building dependency tree
  Reading state information... Done
  libmagickwand-dev is already the newest version.
  The following packages were automatically installed and are no longer required:
    libgraphicsmagick3 libmagick++4 libgraphicsmagick++3 libgraphicsmagick1-dev
    libgraphics-magick-perl libperl5.14 libgraphicsmagick++1-dev
  Use 'apt-get autoremove' to remove them.
  0 upgraded, 0 newly installed, 0 to remove and 40 not upgraded.
  </code></pre></li>
  <li><p>sudo apt-get install libmagickwand-dev imagemagick</p>
  
  <p>Reading package lists... Done
      Building dependency tree
      Reading state information... Done
      imagemagick is already the newest version.
      libmagickwand-dev is already the newest version.
      The following packages were automatically installed and are no longer required:
        libgraphicsmagick3 libmagick++4 libgraphicsmagick++3 libgraphicsmagick1-dev
        libgraphics-magick-perl libperl5.14 libgraphicsmagick++1-dev
      Use 'apt-get autoremove' to remove them.
      0 upgraded, 0 newly installed, 0 to remove and 40 not upgraded.</p></li>
  <li><p>apt-get install libmagickwand-dev</p>
  
  <p>E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
  E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?</p></li>
  <li><p>sudo apt-get install libmagickwand-dev</p>
  
  <p>Reading package lists... Done
  Building dependency tree
  Reading state information... Done
  libmagickwand-dev is already the newest version.
  The following packages were automatically installed and are no longer required:
    libgraphicsmagick3 libmagick++4 libgraphicsmagick++3 libgraphicsmagick1-dev
    libgraphics-magick-perl libperl5.14 libgraphicsmagick++1-dev
  Use 'apt-get autoremove' to remove them.
  0 upgraded, 0 newly installed, 0 to remove and 40 not upgraded.</p></li>
  </ol>
  
  <p>But still the same error message above.</p>