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.
Install brew with
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
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:
Install RVM with
\curl -sSL https://get.rvm.io | bash -s stable
Restart your shell.
Install Ruby with
rvm install 2.7
Then reinstall your gems with bundle install
.
Related Topics
Stubbing Controller Actions in Rspec Request Specs
Mini_Magick Gem Doesn't Work with My Imagemagick Install
How to Create an Association Between Two Rails Models
Ruby on Rails: Create Confirmation View Before Creating the Object
What Does "File.Sync = True" Do
How to Spec Methods That Exit or Abort
Ruby Range: Operators in Case Statement
Error: Error Installing JSON: Error: Failed to Build Gem Native Extension
Ruby: Module, Mixins and Blocks Confusing
How to Get Multiple-Line User Input in Ruby
Ruby 2.1 with Erubis Template Engine
How to Add Iedriverserver to Path
Ruby - Convert Integer to String