Install Gem Gives "Failed to Build Gem Native Extension."

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

There are similar questions:

  • `require': no such file to load -- mkmf (LoadError)
  • Failed to build gem native extension (mkmf (LoadError)) - Ubuntu 12.04

Usually, the solution is:

sudo apt-get install ruby-dev

Or, if that doesn't work, depending on your ruby version, run something like:

sudo apt-get install ruby1.9.1-dev

Should fix your problem.


Still not working? Try the following after installing ruby-dev:

sudo apt-get install make

Install gem gives Failed to build gem native extension.

You need to install make and other build tools first, run this:

sudo apt-get install build-essential

How to install PostgreSQL: ERROR: Failed to build gem native extension

You're missing the Postgres source code and it's needed to compile the pg gem.

  1. Install brew with

     /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
  2. Install PostgreSQL server using

     brew install postgresql

But it also looks like you're using the built-in version of Ruby that ships with macOS. Don't use system Ruby. I suggest installing a Ruby manager like RVM:

  1. Install RVM with

     \curl -sSL https://get.rvm.io | bash -s stable
  2. Restart your shell.

  3. Install Ruby with

     rvm install 2.7

Then reinstall your gems with bundle install.



Related Topics



Leave a reply



Submit