For context, it on a remote server which has a firewall. I'm setting up my environment through a proxy. I have ruby 1.8.7
. When I try to gem install..
sudo gem install --http-proxy <host address>:<port> json
I 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.out
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!
Best Answer
Modern era update, as stated by mimoralea:
or, generic way:
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
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:
Or, for Redhat distro:
Or, for [open]SuSE: