Software⏱️ 2 min read📅 2026-05-31

How to Fix: Error while installing json gem 'mkmf.rb can't find header files for ruby'

The error occurs due to the inability of mkmf.rb to locate the ruby header files. To resolve this, ensure that the ruby development library is installed on the remote server.

Quick Answer: Install the ruby development library and try installing the json gem again.

To resolve the 'Error while installing json gem 'mkmf.rb can't find header files for ruby'' issue, you need to install the development libraries for Ruby on your remote server.

🔧 Proven Troubleshooting Steps

Method 1: Install Development Libraries

  1. Step 1: On your remote server, run the following command to install the development libraries:
sudo apt-get update && sudo apt-get install ruby-dev

Method 2: Use a Ruby Version Manager (RVM)

  1. Step 1: Install RVM on your remote server. You can do this by running the following command:
curl -sSL https://get.rvm.io | bash -s stable

Method 3: Use a Ruby Version Manager (RVM) with a Specific Ruby Version

  1. Step 1: Install RVM with a specific ruby version using the following command:
curl -sSL https://get.rvm.io | bash -s stable --ruby=1.8.7

💡 Conclusion

By following these steps, you should be able to resolve the 'Error while installing json gem 'mkmf.rb can't find header files for ruby'' issue and successfully install the `json` gem.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions