ERROR: Error installing rmagick: in Windows with Ruby 2.2

I had this same issue myself until I finally stumbled upon the answer on Stackoverflow here and here.

Basically you need to follow these steps:

  • Install DevKit. Since I used RailsInstaller to install Ruby on Rails on my laptop, it was already included in the default directory ‘C:\Serever\RailsInstaller\DevKit‘. Otherwise, find the .exe at the RubyInstallers downloads.
  • Install ImageMagick-6.9.5-9-Q16-x86-dll.exe from imagemagick.org. It seems that rmagik2.16 only supports ImageMagick 6, not ImageMagick 7.
  • Make sure that you install the correct version of ImageMagick x86 or x32. If you are unsure what ruby version you have install try this command: ruby -e "puts 1.size". It print 4 if x86 and 8 if x64. answer from here
  • Check the following options on the install screen (more info on the redmine website) :
    • [v] Add application directory to your system path
    • [v] Install development headers and libraries for C and C++
  • Setup in windows environment variables the PATH variable to include the path to ImageMagick. In my case: C:\Server\ImageMagick\. Make sure it is the first variable in the variables list, or you may encounter an “Invalid drive specification” error when extconf.rb tries to identify the ImageMagick version.
  • cd C:\YourRubyProject. Example: C:\Server\htdocs\dev-ruby\redmine.
  • Set CPATH and LIBRARY_PATH environment variables to point respectively to ImageMagick installation directory include and lib subdirectories (so the DevKit will find them at build time)
  • Open C:\Serever\RailsInstaller\DevKit\msys.bat. More details here
  • Run gem install rmagick --platform=ruby -- --with-opt-lib=C:/Server/ImageMagick/lib --with-opt-include=C:/Server/ImageMagick/include. Adjust paths as necessary for your project.
  • Finally, run bundle install, or if necessary bundle update

Note: for those that are looking to install redmine in xampp follow this tutorial. If you get stuck on installing the rmagick lib, return here to this answer and follow the provided steps.

Leave a Comment