Ion Utale
Ion Utale

Reputation: 697

error instaling the cocoapods

here is the error:

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

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/json-1.8.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/json-1.8.1/ext/json/ext/generator/gem_make.out

i've search on google for the last 7 hours and i can't find a solution that works for me. i have tried them all

Please help me up

edit: *after installing the RVM i stil get the same error

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

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/json-1.8.1 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/json-1.8.1/ext/json/ext/generator/gem_make.out

using this command line : sudo gem install cocoapods

Upvotes: 8

Views: 20013

Answers (5)

Amitesh mani tiwari
Amitesh mani tiwari

Reputation: 549

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

It worked for me.

Upvotes: 0

kaioferraz
kaioferraz

Reputation: 1

is just easier install cocoapods separately (eg: using brew), and exporting the path.

Upvotes: -1

Umit KOC
Umit KOC

Reputation: 474

Try "brew install cocoapods" instead and it will get cocoapods installed without this error.

Upvotes: 3

orta
orta

Reputation: 4285

It's customary to advise people to install something like rvm or rbenv before installing CocoaPods. As one of the developers behind CocoaPods I'd like to say that you don't have to do any of that unless you are planning to do ruby work yourself. If you're just interested in getting CocoaPods to work there's no need for all the overhead of a ruby manager.

To quote the CocoaPods guides:

CocoaPods is built with Ruby and it will be installable with the default Ruby available on OS X. You can use a Ruby Version manager, however we recommend that you use the standard Ruby available on OS X unless you know what you're doing.

Using the default Ruby install will require you to use sudo when installing gems. (This is only an issue for the duration of the gem installation, though.)

$ sudo gem install cocoapods

Upvotes: 1

the Tin Man
the Tin Man

Reputation: 160553

You're on Mac OS. To get:

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/include/ruby.h

you're trying to install gems into your system Ruby, which was installed by Apple for their use.

Don't do that.

Instead, use either rbenv or RVM to manage/install Rubies in a separate sandbox, where you're free to fold/spindle/mutilate to your heart's content.

If you opt for RVM, *read the ENTIRE installation instructions* before starting. RVM is very full-featured, and flexible, and those come at a price of additional "options" (AKA "complexity") when installing. Do it as a single-user, do not EVER use sudo, and you should be fine.

We can piggyback on Apple's system-instalation of Ruby, but don't modify it unless you really understand what you're doing; The error above makes me think this isn't the case.

To install a Ruby other than Apple's pre-installed one, odds are really good you'll need the current Xcode, along with the command-line extensions. That will provide the tools necessary to compile native extensions, plus all the headers needed:

Upvotes: 1

Related Questions