3

I am trying to install a gem which has rmagick as a dependency on windows 10. But each time I try to install it, this error appears:

ERROR:  Error installing rmagick:
    ERROR: Failed to build gem native extension.

C:/Ruby22-x64/bin/ruby.exe -r ./siteconf20160126-6648-ks1v6.rb extconf.rb --  with-opt-dir=C:/ImageMagick
*** 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
    --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=C:/Ruby22-x64/bin/$(RUBY_BASE_NAME)
extconf.rb:110:in ``': No such file or directory - identify -version    (Errno::ENOENT)
    from extconf.rb:110:in `configure_compile_options'
    from extconf.rb:16:in `initialize'
    from extconf.rb:517:in `new'
    from extconf.rb:517:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in C:/Ruby22-   x64/lib/ruby/gems/2.2.0/gems/rmagick-2.15.4 for inspection.
Results logged to C:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64- mingw32/2.2.0/rmagick-2.15.4/gem_make.out
Temporarily enhancing PATH to include DevKit...
Building native extensions with: '--with-opt-dir=C:/ImageMagick'
This could take a while...

I have even installed the gem imagemagick, but it doesn't allow me to install rmagick. How are you supposed to install rmagick on windows 10?

metaco57
  • 155
  • 3
  • 15
  • One thing to remember is to close and restart the CommandPrompt after installing ImageMagick. Only then the option "add application to system path" will take effect. – semiomant Apr 13 '16 at 15:38
  • Late at the party. Check out this [answer](http://stackoverflow.com/a/39513938/1903781) on how to install `rmagik` on windows 10. – Adrian Moisa Sep 15 '16 at 14:52

3 Answers3

4

You have to use the correct version of ImageMagick, and have to reference that when you install the gem:

Here is the gem:

gem install rmagick --platform=ruby -- '--with-opt-dir="[path to ImageMagick]"'

Update

Here's a good reference

Here's how to install it step-by-step:

  1. Download & Install ImageMagick

enter image description here

There used to be a problem with newer versions of RMagick; we installed the version 6.9.2, which is working on Win10 x64:

enter image description here

You need to make sure you have the above two checkboxes ticked (C headers && system PATH). The headers are used by the gem to compile (the likely reason for your error); PATH is used to call ImageMagick from the cmd.

You also need to make sure...

  • Install path has no spaces
  • You download dll version of ImageMagick (contains C Headers)
  • We got the HDRI version; it doesn't really matter

--

  1. Install the gem

Like mysql2 etc, you need to make sure you reference the installed libraries in order to get rmagick to install:

gem install rmagick --platform=ruby -- --with-opt-lib="c:/path_to_image_magick/lib" --with-opt-include="c:/path_to_image_magick/include"

This may take a while, but should install.

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Richard Peck
  • 76,116
  • 9
  • 93
  • 147
  • I've tried that countless times, but DevKit keeps preventing the gem from being installed, and the command line stated that DevKit is needed to install the gem. – metaco57 Jan 27 '16 at 21:13
  • There is a trick to doing it. Admittedly, I've forgotten the specifics, we have it running. – Richard Peck Jan 27 '16 at 21:14
  • Yes, and there are not any answers on how to install it online. – metaco57 Jan 27 '16 at 21:36
  • Want to go to chat about it? I remember having to fiddle with it to get it to work – Richard Peck Jan 27 '16 at 21:39
  • Ok, where can we chat? – metaco57 Jan 27 '16 at 21:45
  • 1
    Can someone please show me on this interface of Stack Overflow how to install imagemagick properly with DevKit to install rmagick? – metaco57 Jan 28 '16 at 05:33
  • Update written; if you want to go to chat, I'll help you install it. – Richard Peck Jan 28 '16 at 09:35
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/101865/discussion-between-rich-peck-and-metaco57). – Richard Peck Jan 28 '16 at 10:22
  • Sorry, I don't have enough reputation points to go into chat on here. – metaco57 Jan 28 '16 at 15:47
  • I have wasted 4 hours researching on this. Got it installed last year but this time I had no luck. Thanks to your links I finally got it working.It seems this issue is caused of incompatible Imagemagick and Rmagick versions. I got it working with Imagemagick 6.9.3-2-Q16-HDRI-x64-dll, and rmagick-4.1.2. – Sergio A. Jan 12 '21 at 11:24
  • The current link to imagemagick 6.9 is https://legacy.imagemagick.org/script/download.php#windows – n0rd Oct 20 '22 at 05:45
0

Make sure to use the 32-bit (i.e. x86) versions of ruby AND devkit. For some reason the build process for rmagick crashes with the 64-bit versions.

user2148956
  • 179
  • 1
  • 1
  • 10
0

For anyone stumbling with this problem in 2021, I just installed the latest version of rmagick on Windows, using ImageMagick-6.9.12-33-Q16-HDRI-x64-dll

https://download.imagemagick.org/ImageMagick/download/binaries/

Steps:

Clean up your env variables (PATH) from any previous ImageMagick installation. This is important because the gem will look into each defined path for headers, previous configuration can pollute the installation (it happened to me). Uninstall everything.

  1. Run the installer, include C headers with the checkbox.
  2. Run gem install rmagick --platform=ruby -- '--with-opt-dir="C:\Program Files\ImageMagick-6.9.12-Q16-HDRI"'. Change the folder to your own.
  3. Make sure this folder has been added to your PATH
  4. To verify the installation, run convert. It should call the convert function.

For those wanting to install rmagick in a rails application instead, follow the same steps for ImageMagick, but manually add the PATH. This should be working.

greenymaster69
  • 1,366
  • 1
  • 10
  • 18