Thursday, October 06, 2016

Solve Rails Native Compile Issue

I seldom blog about issue on Windows, because I don't really have a Windows machine with me. This will be an exceptional case that I show how to solve a Rails' native compile issue.

If you see an error from Rails on Windows system, something similar like this

c:> gem install son
...
ERROR: Error installing json:
ERROR: Failed to build gem native extension

The reason is, gem try to build native library to improve performance, but it was not able to do it on your Windows system.

The easiest is to install DevKit from http://rubyinstaller.org/downloads/. The DevKit will be installed at c:\DevKit. Just take note which DevKit to be installed, 32 bits or 64 bits.

Set Windows system PATH environment:
Control Panel > System > Advanced system settings
System Properties > Environment Variables > (Select Path and Edit...), add a new Path
c:\DevKit\bin

start a new command prompt (cmd):
c:> gem install json

You should be able to install json now.