Error while installing json gem ‘mkmf.rb can’t find header files for ruby’

Modern era update, as stated by mimoralea:

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-dev

or, generic way:

sudo apt-get install ruby-dev

or

sudo apt-get install ruby`ruby -e 'puts RUBY_VERSION[/\d+\.\d+/]'`-dev

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:

$ sudo apt-get install ruby-dev

Or, for Redhat distro:

$ sudo yum install ruby-devel

Or, for [open]SuSE:

$ sudo zypper install ruby-devel

Leave a Comment