DEV Community

Dalitso Kasonde
Dalitso Kasonde

Posted on • Updated on

ERROR: Error installing cocoapods: ERROR: Failed to build gem native extension

Solution worked for Mac Big Sur OS

NOTE : replace user_name - with your laptop user name

  1. Check the version of Ruby

    ruby -v

Also check the given path:
which ruby

  1. Use Homebrew to install the latest Ruby

    brew install ruby

Binaries installed by gem will be placed into:

/usr/local/lib/ruby/gems/2.7.0/bin

  1. Add this to your PATH.

If you need to have ruby first in your PATH run:

echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> /Users/user_name/.bash_profile

  1. For compilers to find ruby you may need to set:

export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include"

  1. Follow the below instructions to set PATH. Now you will go to see the installed Ruby.

echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> /Users/user_name/.bash_profile

echo 'export LDFLAGS="-L/usr/local/opt/ruby/lib"' >> ~/.bash_profile

echo 'export CPPFLAGS="-I/usr/local/opt/ruby/include"' >> ~/.bash_profile

source ~/.bash_profile

  1. Finally, Make sure your PATH is in place.

ruby -v

which ruby

  1. Make sure you install by specifying the save destination as follows.

sudo gem install -n /usr/local/bin cocoapods

Top comments (1)

Collapse
 
kanggara75 profile image
Call Vin

Work for me