Software⏱️ 3 min read📅 2026-06-03

How to Fix: Unable to install gem - Failed to build gem native extension - cannot load such file -- mkmf (LoadError)

Failed to build gem native extension error in Ruby 1.9.3.

Quick Answer: Try updating the system's GCC compiler and re-run the bundle command.

The error 'Failed to build gem native extension' occurs when trying to install gems, specifically affecting users of Ruby 1.9.3. This issue happens because the system cannot locate or compile the necessary files for the installed gems.

This problem can be frustrating as it prevents the installation of desired gems and hinders the progress of development projects. In this guide, we will walk you through the steps to resolve this error.

💡 Why You Are Getting This Error

  • The primary reason for this error is that RubyGems requires a C compiler to build native extensions. However, on Ubuntu systems like yours, the C compiler might not be properly installed or configured.
  • An alternative reason could be issues with the system's library paths or conflicting package installations.

🔧 Proven Troubleshooting Steps

Install and configure the necessary C compiler

  1. Step 1: Update your package list to ensure you have the latest versions of packages: `sudo apt-get update`.
  2. Step 2: Install the necessary C compiler, typically 'build-essential': `sudo apt-get install build-essential`.
  3. Step 3: Verify that the C compiler is installed and configured correctly by running `gcc --version` in the terminal.

Update system library paths

  1. Step 1: Run `sudo dpkg -l | grep libcc1-` to check if the required libraries are installed.
  2. Step 2: If necessary, install the required libraries using `sudo apt-get install libcc1-4-dev` or `sudo apt-get install build-essential`.

💡 Conclusion

By following these steps, you should be able to resolve the 'Failed to build gem native extension' error and successfully install gems. Remember to restart your terminal after making any changes to ensure they take effect.

Did this fix your problem?

If not, try searching for specific error codes.

🔍 Search Error Database

❓ Frequently Asked Questions