0

When I perform sudo gem install cocoapods it returns the following:

Building native extensions. This could take a while...
ERROR:  Error installing cocoapods:
    ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.12.2/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20200524-27428-t6f6h6.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/include/ruby.h

You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.

extconf failed, exit code 1

Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.12.2 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/ffi-1.12.2/gem_make.out

Any idea what the problem is?

Zorgan
  • 8,227
  • 23
  • 106
  • 207
  • Do not ever do this! The Ruby that ships as part of macOS is *only for internal use by Apple itself*. If you want to use Ruby, *you must install an appropriate Ruby implementation yourself*. – Jörg W Mittag May 24 '20 at 09:06

1 Answers1

4

First install Homebrew if you don't have it: https://brew.sh/index_pt-br

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

Second, install ruby if you don't have it: https://www.ruby-lang.org/pt/documentation/installation/

brew install ruby

You can also follow these steps: https://gist.github.com/monicao/d372716cdfbb7e9cf692

Then, close your terminal and reopen it again.

Always use sudo to install cocoapods:

sudo gem install cocoapods

Also, you need to install Xcode's developer tools. The easiest way to do this is through terminal (this question)

xcode-select --install
Frankenstein
  • 15,732
  • 4
  • 22
  • 47