nokogiri ERROR Failed to build gem native extension on MAC

During bundle install, a lot of time we use to get following error because of nokogiri gem. This error generally occur on MAC OSX. There are few other gems as well which throw the same error like pg, rmagic etc. But the way we resolve this problem is same for most of them. So Lets see how we can resolve this issue.

This is a very wiered error we get while installing gems and its not very easy to figure out why this happens but actually, Its not that hard to fix as it looks.

Solution

The above error means that the file “/usr/include/iconv” is missing in your build environment and which also means that your Xcode Command Line Tools are not installed properly. Open your terminal and run the following command

It will open a GUI application as shown belowClick on install button and done.

xcode-install

Now if you run

And there you go,  your problem is solved.

 

Leave a Reply

Your email address will not be published. Required fields are marked *