Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS

Rashii Henry
Rashii Henry
16,433 Points

Error Installing Cocoapods

whenever i run the command:

sudo gem install cocoapods

i run across the following error message:

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

im new to cocoapods so could anyone assist me? I'm running OSX version 10.9.2

7 Answers

Rashii Henry
Rashii Henry
16,433 Points

I found a solution to my problem. after running : sudo ln -s /usr/bin/gcc /usr/bin/gcc-4.2

cocoapods installed successfully.

Rashii Henry
Rashii Henry
16,433 Points

from that stack overflow answer i've already updated my command line tools. are you suggesting that i install homebrew and run the command :

brew install apple-gcc42

Patrick Donahue
Patrick Donahue
9,523 Points

It seems like you may not have Ruby installed.

Rashii Henry
Rashii Henry
16,433 Points

i do have ruby installed. check what i put under Amit's answer.

Amit Bijlani
STAFF
Amit Bijlani
Treehouse Guest Teacher

Here's a checklist that might help:

  1. Do you have multiple versions of Ruby? Do you have rvm or rbenv installed? If so, you have to make sure you are installing the CocoaPod gem to the right version.
  2. Do you have the latest version of Xcode?
  3. Do you have multiple versions of Xcode? If you do, then use the xcode-select to select the latest version of Xcode.
  4. Finally, here's another workaround that helped others: https://gist.github.com/goshakkk/5763489
Rashii Henry
Rashii Henry
16,433 Points

Here's my output when i run the command ruby -v: ichange-lives:~ rashiihenry$ ruby -v ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin10.8.0] ichange-lives:~ rashiihenry$

i'm currently running the latest version Xcode version 5.1.

Rashii Henry
Rashii Henry
16,433 Points

i have the latest of everything installed, thats why i confused about not being able to install cocoapods. matter of fact heres all the output:

ichange-lives:~ rashiihenry$ sudo gem install cocoapods Password: Building native extensions. This could take a while... ERROR: Error installing cocoapods: ERROR: Failed to build gem native extension.

    "/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby" -rubygems /usr/local/rvm/gems/ruby-1.9.3-p392/gems/rake-10.1.1/bin/rake RUBYARCHDIR=/usr/local/rvm/gems/ruby-1.9.3-p392/gems/xcodeproj-0.14.1/ext RUBYLIBDIR=/usr/local/rvm/gems/ruby-1.9.3-p392/gems/xcodeproj-0.14.1/ext

/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb checking for -std=c99 option to compiler... *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options.

Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/mkmf.rb:381:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/mkmf.rb:491:inblock in try_compile' from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/mkmf.rb:443:in with_werror' from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/mkmf.rb:491:intry_compile' from extconf.rb:24:in block in <main>' from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/mkmf.rb:790:inblock in checking_for' from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/mkmf.rb:284:in block (2 levels) in postpone' from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/mkmf.rb:254:inopen' from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/mkmf.rb:284:in block in postpone' from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/mkmf.rb:254:inopen' from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/mkmf.rb:280:in postpone' from /usr/local/rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/mkmf.rb:789:inchecking_for' from extconf.rb:23:in <main>' rake aborted! Command failed with status (1): [/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/...] /usr/local/rvm/gems/ruby-1.9.3-p392/gems/xcodeproj-0.14.1/ext/xcodeproj/Rakefile:37:inblock in <top (required)>' Tasks: TOP => default => ext (See full trace by running task with --trace)

Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p392/gems/xcodeproj-0.14.1 for inspection. Results logged to /usr/local/rvm/gems/ruby-1.9.3-p392/gems/xcodeproj-0.14.1/ext/xcodeproj/gem_make.out ichange-lives:~ rashiihenry$

Amit Bijlani
Amit Bijlani
Treehouse Guest Teacher

The error you posted above says: "You have to install development tools first", which means that it cannot find a compiler.

Try this from the command line:

xcode-select --install

It will install the command line tools.

Rashii Henry
Rashii Henry
16,433 Points

When i tried to download them, this was the message i was getting: cannot install the software because it is not currently available from the software update server.

Rashii Henry
Rashii Henry
16,433 Points

I keep getting an email to vote for the best answer but my question wasn't answered in this discussion. :/