In my efforts to install Ruby on Rails and SpreeCommerce on my Windows 7 laptop, the problem that stumped me the longest was the ‘
spree install my_store‘ command that gave me the error:
'identify' is not recognized as an internal or external command,
operable program or batch file.
Image magick must be installed.
I tried running ‘
gem install rmagick‘ first, which installed something, but it was still not sufficient to let me run the ‘
spree install my_store‘ command without aborting in an error.
After much searching on Google and concatenating all these outdated sources, I finally figured it out. Steps (and troubleshooting details) are below.
- Install the Ruby DevKit if you do not have it already. Since I used RailsInstaller to install Ruby on Rails on my laptop, it was already included in the default directory ‘
C:\RailsInstaller\DevKit‘. Otherwise, find the .exe at the RubyInstallers downloads. To install,
Download it, run it to extract it somewhere (permanent). Then cd to it, run “
ruby dk.rb init” and “
ruby dk.rb install” to bind it to ruby installations in your path. [source]
Install a compatible version of ImageMagick on your Windows machine. The version that worked for me with Ruby v1.9.3v484 and Rails v4.0.4 was ImageMagick v18.104.22.168, 32-bit (direct download here). Supposedly, ImageMagick v22.214.171.124 is the latest version that will work. [source] For different archived versions, see here. The most recent ImageMagick v6.8.x gave me errors which made me go hunting for more troubleshooting instructions. If the ImageMagick installer hangs when you try to open it from your downloads folder, try right-clicking and ‘
Run as administrator‘.
Make sure to install 32-bit even if you have a 64-bit machine. Installing the 64-bit version will make your
rmagickgem installation fail. [source]
If you have a previous installation of ImageMagick, make sure to uninstall it first. If you can’t find the ImageMagick uninstaller in your ‘
Add/Remove Programs‘, check your installation folder (e.g.
unins000.exe. Deleting the installation folder will not properly remove all registry and path settings. [source]
If you have a previous incompatible rmagick version installed, you can uninstall it using the command ‘
gem uninstall rmagick‘. Check for its existence with the command ‘
Some notes about the installation process:
Install ImageMagick into a path with no spaces. The default ‘
C:\Program Files (x86)\ImageMagick-x.x.x‘ will have spaces. I used ‘
C:\ImageMagick‘ to keep it simple.
Select the options ‘
Add application directory to your system path‘ and ‘
Install development headers and libraries for C and C++‘.
Make sure that ImageMagick is first in the path, or you may encounter an “Invalid drive specification” error when
extconf.rbtries to identify the ImageMagick version. [source] If you selected the ‘
Add application directory to your system path‘ option from the previous tip, you should be fine.
Otherwise, to double-check, go to ‘
Start‘ > right click on ‘
My Computer‘ > ‘
Properties‘ > left hand side for ‘
Advanced system properties‘ > ‘
Environment variables‘ button. In the ‘
System variables‘ section, look for the ‘
Path‘ variable and check that ‘
C:\ImageMagick‘ (or the name of your ImageMagick installation directory) is first in the list.
rmagickgem. If you have a compiler in your command line, just use ‘
cmd.exe‘ from your Start Menu. Otherwise, use the command line available in the DevKit at the default installation path ‘
Run the command ‘
gem install rmagick --platform=ruby -- --with-opt-dir=c:/ImageMagick‘ and substitute the directory with your ImageMagick installation path if you named it something else. If you messed up and still left spaces in your installation path, use the command style ‘
gem install rmagick -- '--with-opt-dir="[path to ImageMagick]"'‘ with the extra single quotes around the
--with-opt-diroption and double-quotes around the path.
Double-check that RMagick has now been successfully installed by running ‘
gem list‘ and looking for the rmagick gem or ‘
May you have less frustration with these up-to-date (for now) instructions than I did!