debugrubyCritical
Error while installing json gem 'mkmf.rb can't find header files for ruby'
Viewed 0 times
errorwhileinstallinggemfindheaderfilesforrubymkmf
Problem
For context, it on a remote server which has a firewall. I'm setting up my environment through a proxy. I have
I get the following error:
Since I was unsure what the problem is, I googled and found these
-
gem install: Failed to build gem native extension (can't find header files) - the instructions here seem to be specific to the gem being installed.
-
How to install json gem - Failed to build gem native extension This seems to be slightly different error.
Any hints? Thanks!
ruby 1.8.7. When I try to gem install..sudo gem install --http-proxy : jsonI get the following error:
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/ruby.h
Gem files will remain installed in /usr/lib64/ruby/gems/1.8/gems/json-1.8.1 for inspection.
Results logged to /usr/lib64/ruby/gems/1.8/gems/json-1.8.1/ext/json/ext/generator/gem_make.outSince I was unsure what the problem is, I googled and found these
-
gem install: Failed to build gem native extension (can't find header files) - the instructions here seem to be specific to the gem being installed.
-
How to install json gem - Failed to build gem native extension This seems to be slightly different error.
Any hints? Thanks!
Solution
Modern era update, as stated by mimoralea:
In case that you are using ruby 2.0 or 2.2 (thanks @patrick-davey).
or, generic way:
or
The first link you’ve posted is exactly your case: there is no ruby development environment installed. Development env is needed to compile ruby extensions, which are mostly written in
I would suggest you to install
Try:
Or, for Redhat distro:
Or, for [open]SuSE:
In case that you are using ruby 2.0 or 2.2 (thanks @patrick-davey).
sudo apt-get install ruby2.0-dev
sudo apt-get install ruby2.2-dev
sudo apt-get install ruby2.3-devor, generic way:
sudo apt-get install ruby-devor
sudo apt-get install ruby`ruby -e 'puts RUBY_VERSION[/\d+\.\d+/]'`-devThe first link you’ve posted is exactly your case: there is no ruby development environment installed. Development env is needed to compile ruby extensions, which are mostly written in
C. Proxy has nothing to do with the problem: everything is downloaded fine, just compilation fails.I would suggest you to install
ruby-dev (ruby-devel for rpm-based distros) package onto you target machine.gcc package might be needed as well.Try:
$ sudo apt-get install ruby-devOr, for Redhat distro:
$ sudo yum install ruby-develOr, for [open]SuSE:
$ sudo zypper install ruby-develCode Snippets
sudo apt-get install ruby2.0-dev
sudo apt-get install ruby2.2-dev
sudo apt-get install ruby2.3-devsudo apt-get install ruby-devsudo apt-get install ruby`ruby -e 'puts RUBY_VERSION[/\d+\.\d+/]'`-dev$ sudo apt-get install ruby-dev$ sudo yum install ruby-develContext
Stack Overflow Q#20559255, score: 941
Revisions (0)
No revisions yet.