12

Ruby version: 2.2.5

Mac OSX: 10.11.5

Gem version: 2.4.8

Bundler version: 1.12.5

When I run gem install nokogiri -v '1.5.11', I got the following error:

Building native extensions. This could take a while...
ERROR:  Error installing nokogiri:
ERROR: Failed to build gem native extension.

/Users/hwpeng/.rvm/rubies/ruby-2.2.5/bin/ruby -r ./siteconf20160707-31800-1ejznjc.rb extconf.rb

====ignored multiple lines====

make "DESTDIR=" install
make: /usr/local/bin/gmkdir: No such file or directory
make: *** [.RUBYARCHDIR.-.nokogiri.time] Error 1

make install failed, exit code 2
Community
  • 1
  • 1
Max Peng
  • 2,501
  • 1
  • 24
  • 40

3 Answers3

44

I noticed the error message said: make: /usr/local/bin/gmkdir: No such file or directory.

I searched this in google and found a similar post but for cocopods: https://coderwall.com/p/ehijxg/fixing-error-installing-cocoapods-on-macos

The following commands solved my problem. If you have a different error message, please refer to http://www.nokogiri.org/tutorials/installing_nokogiri.html

Homebrew

brew install coreutils
gem install nokogiri -v '1.5.11'

MacPorts

sudo port install coreutils
gem install nokogiri -v '1.5.11'
ioquatix
  • 1,361
  • 15
  • 31
Max Peng
  • 2,501
  • 1
  • 24
  • 40
  • 4
    Installing coreutils did the trick for me. Had some error with json 1.8.3 and ruby 2.2.5. – Yoni Sep 13 '16 at 21:43
  • Why do gem authors assume global packages are installed and don't check for them or include them in install instructions? – Andy Ray Oct 24 '18 at 18:44
  • I had an issue installing `rugged` and `coreutils` was the issue. Thanks – ninyarko Apr 21 '20 at 05:09
2

I had this problem last time and you can try this code:

gem install nokogiri -v 1.5.11 -- --use-system-libraries

I think it will work.

Khanh Pham
  • 2,732
  • 2
  • 27
  • 34
0

The issue is not directly linked with the nokogiri. It is more around the missing libraries in the system. I am using Mac M1 machine and moving data/libraries from Intel to M1 is a pain. So for me after spending hours I fixed the issue. Steps which I followed to fix library issues are:

  • Uninstall and install Homebrew
  • Update the proper PATH in .zshrc or .bachrc file
  • install the coreutils brew install coreutils
  • close the terminal and then run the bundle install

Credit for coreutils help: http://thoughtsthatleakedout.blogspot.com/2011/10/problem-with-gmkdir-when-updating-gems.html

Touseef Murtaza
  • 934
  • 10
  • 16