1

I have this problem on my linux OS:

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

    current directory: /var/lib/gems/2.3.0/gems/nokogiri-1.8.1/ext/nokogiri
/usr/bin/ruby2.3 -r ./siteconf20171120-5536-amlck4.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.3.0/gems/nokogiri-1.8.1 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/nokogiri-1.8.1/gem_make.out

How do I fix this issue from the above logs?

Philip Mutua
  • 6,016
  • 12
  • 41
  • 84

2 Answers2

2

When I run sudo apt-get install ruby-dev zlib1g-dev liblzma-dev I got these logs:

build-essential patch
Reading package lists... Done
Building dependency tree       
Reading state information... Done
build-essential is already the newest version (12.1ubuntu2).
patch is already the newest version (2.7.5-1).
zlib1g-dev is already the newest version (1:1.2.8.dfsg-2ubuntu4.1).
zlib1g-dev set to manually installed.
You might want to run 'apt-get -f install' to correct these:
The following packages have unmet dependencies:
 ruby-dev : Depends: ruby2.3-dev but it is not going to be installed
 slack-desktop : Depends: libappindicator1 but it is not going to be installed
E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

So to solve this problem I run apt-get -f install

Then I run sudo apt-get install ruby-dev zlib1g-dev liblzma-dev dependencies were successfully installed.

gem native extension successfully build.

Philip Mutua
  • 6,016
  • 12
  • 41
  • 84
1

I was getting the same error with the ruby2.4.4-alpine and ruby2.4.4-slim Docker images, just changing to ruby2.4.4-jasmine solved the problem.

Mateus Luiz
  • 756
  • 7
  • 20