💉 How To Install The RMagick 💉 #RubyOnRails Gem on Windows 7/8/10 (ImageMagick 6.9.6 Q16-HDRI)

Step-by-Step guide on installing the RMAGICK gem on Windows 7/8/10…

--

RMagick requires a valid ImageMagick installation

⚠️ The rmagick gem will NOT install on Windows unless you have ImageMagick installed…⚠️

ImageMagick is an image manipulation library (Photoshop without a GUI).

Whilst installing is a relatively simple process, there are several important facets to making it work correctly (version 7 doesn’t work).

The main reason you need to know this is because without a correctly installed version of ImageMagick, you’ll receive the “ERROR: Failed To Build Native Extension” error:

Failed to build gem native extension Windows 10

It is caused by Windows’ inability to reference ImageMagick ‘C’ header files.

C Header files are used by all programs to enabled a number of different features. Linux systems also need these references, but can be installed by apt-get. With Windows, you have to download them independently…

1️⃣ Download & Install ImageMagick 6.9.x (free)

ImageMagick is FREE to download —but BEWARE — you need to download a 6.9.x version for it to work…

➡️ Download from **THIS URL (6.9.6)** (needs to be DLL version) ⬅️

You should NOT download the latest version of ImageMagick (7.x) because it doesn’t work with RMagick. We’ve tried it. The only versions which currently work are 6.9.x. To download them, you need to use this hosted repository:

This repository has archived versions of ImageMagick (considering the latest doesn’t work with the gem)…

We currently use ImageMagick 6.9.6 Q16-HDRI DLL (64bit):

When downloading the version you want, you need to look for several things…

  1. You NEED To download the DLL version. This gives you access to the C headers which RMagick needs to compile (see below).
  2. You need to make sure you are downloading the appropriate version for your system. Many versions of Windows are 64-bit. Whilst this means nothing to most, it basically gives the system access to more memory addresses.
  3. When installing software, using the 64 bit version gives it access to these memory addresses, speeding up the system. If you don’t know, or don’t care, just use the X86 (32-bit) version. If you want maximum performance, download the 64 bit version.

You can see how to check your version of Windows here:

Windows 10 64-Bit

Once you’ve found the version you wish to download, you need to click on the EXE variant:

2️⃣ Install

Once you have downloaded ImageMagick, install it to a path without spaces. You also need to make sure you check the following options:

This will install an actual piece of software on your system:

You can check to see if your installation was successful by using the
convert -version command in CMD:

Type “convert — version” in CMD to test ImageMagick’s installation

This will verify ImageMagick is installed (can be referenced by RMagick).

If this passes, it means you should then try and install the RMagick gem, referencing the new ImageMagick install files you’ve just put on your computer.

3️⃣ RMagick (Gem)

Next, install the RMagick gem with reference to the installation path of ImageMagick:

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

You need to make sure you reference the paths with forward-slashes otherwise it won’t work.

This will take some time but should work if you have the correct version of ImageMagick installed (7.x doesn’t work). Once this has been installed, it should work in your apps.

📆 UPDATE 2018 (RMAGICK2.so Error)

“The Specific Module Could Not Be Found” — ….. “RMagick2.so” Errors Occur When Ruby Can’t Find The ImageMagick DLL’s

If you’re using RubyInstaller2 on Windows, the ONLY way to get RMagick working on this version is to copy the core Imagemagick DLL files to your Ruby/bin folder:

To do this, you need to click into the ImageMagick base directory and copy the above files to your Ruby/bin folder:

Copy these files from the ImageMagick folder to the Ruby/bin folder

📆 UPDATE 2 (2018) — Paperclip Spoof Error

Content Type Spoof: Filename XXX.jpg (application/octet-stream from Headers, [“image/jpeg”] from Extension), content type discovered from file command ____.

Another problem you’ll face is a lack of file command.

This will prevent Paperclip from being able to check the file type of uploads:

In unix , you need to set command_path in the environment files of Rails:

In Windows , you need to copy a version of fileto a PATH directory. This would normally have been handled by devkit but as RubyInstaller2 uses msys2 , you may need to do it manually.

There are TWO ways:

1️⃣ (IF NOT USING MSYS2)
Download a copy of file and put it on your HDD (easiest):

Download the ZIP version, you don’t need the setup.

Save BOTH files to your HDD, then unzip them into the SAME folder
(one contains two dll file dependencies):

Once the folder has the required files, add the bin directory to your PATH:

  • Press “Windows” + “R” keys on your keyboard
  • In the “Run” dialogue, type sysdm.cpl and press “OK”:
  • This will load the “System” dialogue
  • Click “Advanced” → “Environment Variables”:
  • This will load the “Environment Variables” dialogue (which differs between Windows 7 & Windows 10):
Windows 10
Windows 7

Ensure you add the full path to your file directory, specifically pointing to the /bin dir. This will allow Windows to load up the file.exe application when using cmd.

After this, load a fresh instance of cmd test thefile command —
it should show the following:

This should fix the spoofing error with Paperclip & Rails on Windows.

2️⃣ (IF USING MSYS2)
Run rails with the ridk exec command (uses msys2):

This will ensure the file package is installed with msys2 .

From here, you’ll need to reference it when running Rails:

This will allow you to run Paperclip without any issues:

Obviously, referencing ridk exec every time you run rails is a pain.

If you’d prefer to set and forget, you should just download file and put it in the PATH var on your system. This way, cmd will have access to it all the time.

☎️ Further Support ☎️

If you need further support, please feel free to contact us → we’re in the UK so please consider the ⌚ difference!


We have a 👾PCFixes.com👾 live chat support channel at https://www.pcfixes.com/ → available 24/7

👾PCFixes.com👾 Is Currently Voted The ⭐️Best Live Tech Support⭐️Service

Live support is recommend IF you use your system for business or work.

If you need the help right now, getting an expert on screen gives you the ability to at least get a second opinion (and perhaps someone to help guide you through the fix). Live support is the only way to do this.

⚠️ Do NOT use live services that charge up front. ONLY use companies who provide live support without ANY up-front commitments…⚠️

✔️ PCFixes.com is the only recognized online system repair service
✔️ PCFixes.com is operated from the UK by veteran PC repair technicians
✔️ PCFixes.com gives 24/7 support to anyone needing system repairs

📴 PCFixes.com also resolves issues with Android & iPhone

⭐️⭐⭐️⭐️⭐️

PCFixes.com is FREE to talk to anyone and you’re welcome to stay on the line for as long as you require to get things fixed.

The real benefit of PCFixes.com lies in its contributor network → if you cannot get your system fixed directly, you can use their local network (call an out an expert to come and solve the issue for you)…

👾 PCFixes.com 👾 provides 24/7 LIVE support which gives you the ability to connect with real people to get specific solutions for your system.

If you need any help identifying or solving the problem you’re experiencing, it’s worth using the service to gain a second opinion. If you want to keep them on the line whilst you try and fix it, you’re very welcome to do that…

📥 Thanks For Reading! 📥

If you need further help, please feel free to ask below…

--

--