I get this following when I try to install nokigiri,

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

    current directory: /var/lib/gems/2.4.0/gems/nokogiri-1.9.1/ext/nokogiri
/usr/bin/ruby2.4 -r ./siteconf20181224-15718-15hfw3z.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.4.0/gems/nokogiri-1.9.1 for inspection.
Results logged to /var/lib/gems/2.4.0/extensions/x86_64-linux/2.4.0/nokogiri-1.9.1/gem_make.out

I have tried installing ruby-dev1, zlib1g-dev and liblzma-dev, didn't help. I also installed build-essential patch, ruby-dev version 2.0.0,2.0.2,2.0.3 that also didn't help.

  • 4
    This looks like it expects a newer ruby version, have you tried installing ruby2.4-dev?
    – quassy
    Dec 25, 2018 at 23:10

1 Answer 1


Installing ruby2.4-dev did the work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.