I know this is a common problem, so I've searched all the issues but haven't found a solution to it. Hoping someone can point me in the right direction.
When I run gem install cocoapods
, I get this:
~/ gem install cocoapods
Building native extensions. This could take a while...
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
/usr/local/bin/ruby -rubygems /usr/local/lib/ruby/gems/2.1.0/gems/rake-10.1.1/bin/rake RUBYARCHDIR=/Users/jh/.gem/ruby/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/xcodeproj-0.14.1 RUBYLIBDIR=/Users/jh/.gem/ruby/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/xcodeproj-0.14.1
/usr/local/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
--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/bin/ruby
/usr/local/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /usr/local/lib/ruby/2.1.0/mkmf.rb:571:in `block in try_compile'
from /usr/local/lib/ruby/2.1.0/mkmf.rb:524:in `with_werror'
from /usr/local/lib/ruby/2.1.0/mkmf.rb:571:in `try_compile'
from extconf.rb:24:in `block in <main>'
from /usr/local/lib/ruby/2.1.0/mkmf.rb:918:in `block in checking_for'
from /usr/local/lib/ruby/2.1.0/mkmf.rb:351:in `block (2 levels) in postpone'
from /usr/local/lib/ruby/2.1.0/mkmf.rb:321:in `open'
from /usr/local/lib/ruby/2.1.0/mkmf.rb:351:in `block in postpone'
from /usr/local/lib/ruby/2.1.0/mkmf.rb:321:in `open'
from /usr/local/lib/ruby/2.1.0/mkmf.rb:347:in `postpone'
from /usr/local/lib/ruby/2.1.0/mkmf.rb:917:in `checking_for'
from extconf.rb:23:in `<main>'
rake aborted!
Command failed with status (1): [/usr/local/bin/ruby extconf.rb...]
/Users/jh/.gem/ruby/2.1.0/gems/xcodeproj-0.14.1/ext/xcodeproj/Rakefile:37:in `block in <top (required)>'
Tasks: TOP => default => ext
(See full trace by running task with --trace)
rake failed, exit code 1
Gem files will remain installed in /Users/jh/.gem/ruby/2.1.0/gems/xcodeproj-0.14.1 for inspection.
Results logged to /Users/jh/.gem/ruby/2.1.0/extensions/x86_64-darwin-13/2.1.0-static/xcodeproj-0.14.1/gem_make.out
~/
I've already run xcode-select --install
. Any ideas?
Mavericks 10.9.1, Xcode 5.0.2, Ruby 2.1.0-p0.
Cocoapods worked fine with the previous version of Ruby, by the way. I don't believe anything has changed, but I'm not entirely sure.
How did you install Ruby 2.1.0, and how were you using 2.0.0 before?
I used:
brew install ruby-install
ruby-install -i /usr/local/bin ruby 2.1.0
It's the same way I installed Ruby 2.0. I am trying to remember, though, whether I had the same problem with Ruby 2.0 and how I fixed it. I think I did have an issue.
It seems that it's unable to find the compiler. But:
~/ which gcc
/usr/bin/gcc
~/ which gcc-4.2
/usr/local/bin/gcc-4.2
~/ gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 5.0 (clang-500.2.79) (based on LLVM 3.3svn)
Target: x86_64-apple-darwin13.0.0
Thread model: posix
~/ gcc-4.2 -v
Using built-in specs.
Target: i686-apple-darwin11
Configured with: /Volumes/Media/Builds/gcc-5666.3/build/obj/src/configure --disable-checking --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++,fortran --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Apple Inc. build 5666) (dot 3)
You've gotta be kidding me. I was just messing around and all of a sudden it installed.
~/ gem install cocoapods
Building native extensions. This could take a while...
Successfully installed xcodeproj-0.14.1
Fetching: cocoapods-try-release-fix-0.1.1.gem (100%)
Successfully installed cocoapods-try-release-fix-0.1.1
Fetching: cocoapods-0.29.0.gem (100%)
The problem is, I'm not sure what I did. :/
0.o
I guess I did symlink gcc
into /usr/local/bin. Not sure why that would have made a difference.
~/ which gcc
/usr/local/bin/gcc
~/ ls -al /usr/local/bin/gcc
lrwxr-xr-x 1 jh admin 12 Jan 2 15:10 /usr/local/bin/gcc -> /usr/bin/gcc
I'm not familiar with the ins and outs of RubyGems but it would seem that it wasn't searching /usr/bin, if that was the only change you made. @alloy or @irrationalfab will want to take a look, I think, since they are very pro at this.
Did you by chance do xcode-select --install
?
I'm wondering if the "development tools" meant there was an issue with the xcode build system?
Yeah, xcode-select --install
several times before, never helped.
Development tools usually is a gcc issue.
(which is part of what xcode-select --install
does)
My guess (sorta based on what I have seen trying to solve this myself) is that gem has to rebuilt to be "modern". I was using a version of gem that was old. I rebuilt 1.9.3-484 and gem with it, and things began to work. I had issues with the atomic
gem.
In my case I had no such /usr/bin/gcc-4.2
brew install apple-gcc42 solved the issue
Symlinking llvm
as gcc
makes works on Maverics as well:
sudo ln -s /usr/bin/llvm-gcc /usr/bin/gcc-4.2
For future googlers, rehashing rbenv solved this issue for me.
rbenv rehash
@akisaarinen thanks. That worked for me.
@akisaarinen that worked for me - thanks!
@akisaarinen Finally something that works! Thank's a lot!
@akisaarinen That did the trick :D
Symlinking is described in the troubleshooting guide: http://guides.cocoapods.org/using/troubleshooting.html.
@akisaarinen bingo! symlinking the compiler did solve
ERROR: While executing gem ... (Errno::EACCES)
Permission denied - /Users/walther/.rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/gems/mysql2-0.3.15/MIT-LICENSE
for me too
thanks so much for sharing!
I have the same problem.
Mavericks Mac OS X 10.9.3,
Ruby ruby 1.9.3p448
Xcode Version 5.1.1
xcode-select --install
Updating command line tool can not be completed. I have installed latest version of the command line tools from the file command_line_tools_for_osx_mavericks_april_2014.dmg
~/ which gcc
/usr/bin/gcc
~/ which gcc-4.2
/usr/bin/gcc-4.2
~/ which llvm-gcc
/usr/bin/llvm-gcc
~/ llvm-gcc --version
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.2.0
Thread model: posix
~/ xcode-select -v
xcode-select version 2333.
~/ ls -al /usr/local/bin/
lrwxr-xr-x 1 root wheel 17 May 31 22:40 gcc-4.2 -> /usr/bin/llvm-gcc
I have already symlinked llvm-gcc with gcc-4.2 but didn't solve my problem.
My problem is caused by ruby. After upgrade ruby version I can install cocoapods without error.
ruby-2.1.2
As for me, it was a long way. I had similar problem on Mac, that I haven't used for half a year, but need to setup again. So I was trying to update Cocoapods.
Not sure what steps are actually needed from these:
xcode-select --install
. rvm get stable --ruby
.zshrc
file➜ ✗ ruby --version
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
➜ ✗ whereis ruby
/usr/bin/ruby
➜ sudo ln -s /usr/bin/gcc /usr/local/bin/gcc
➜ ls -al /usr/local/bin/gcc
lrwxr-xr-x 1 root admin 12 Jul 9 15:05 /usr/local/bin/gcc -> /usr/bin/gcc
But I found that I should remove old repos and setup new:
pod repo remove master
pod setup
I had a similar error, while doing something unrelated to CocoaPods and Google lead me here. So incase it helps a future googler, I fixed my problem by:
gcc
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
- so I ran
sudo gcc
- next it said:
You have not agreed to the Xcode license agreements. You must agree to both license agreements below in order to use Xcode.
Hit the Enter key to view the license agreements at '/Applications/Xcode.app/Contents/Resources/English.lproj/License.rtf'
After going through that process, and agreeing to the license, everything worked.
Thanks, @akisaarinen . Seems the symlink previously was pointing the wrong place!
Used rbenv to install ruby 2.1.2 'rbenv install 2.1.2', configured local version with 'rbenv local 2.1.2', rehash (I'm using zsh) and reran 'sudo gem pristine --all' without any errors. Xcode select is set to xcode 6 beta 7.
Thank you for the suggestions.
Upgrading ruby also worked for me.
updating ruby works for me on Xcode 6 and OS X Yosemite beta 7
If you just upgrade Xcode, you may have not agreed to the Xcode license.
I just encounter this issue, and it's the reason for me. I fixed it via open Xcode app and agree to the Xcode license.
Hope this can help.
Thanks @HenryYan2012, it worked for me
@gmale's fix worked for me
@akisaarinen thanks. That worked for me.
I had a similar error trying to install cucumber. Inspired by the mention of llvm-gcc, I checked to see if it existed.
sudo llvm-gcc
It turns out I hadn't agreed to the terms and conditions since the last update. Did so just now, and the gem installs without issue.
I updated recently OSX to Yosemite, and then i started seeing this error. Thanks @HenryYan2012 .
Opened XCode, Accepted the license.
Also, i ran 'sudo ln -s /usr/bin/gcc /usr/local/bin/gcc' (Not sure if it was needed)
'bundle install' is working fine now.
@vk2sky
Thank you! That solved my problem.
Happy to have helped, @mesutk.
There should currently no longer be any gems that require compilation. Can you please specify which gem needed it?
Hi @alloy, I'm not sure if that question was addressed to me...
I was not using CocoaPods. From memory, one gem that gave the error was ruby-debug-ide, and there were others. So there are gems out there that do require compilation.
But I suspect that you were meant gems reference by CocoaPods, in which case you can safely disregard my comments :-)
Cheers,
Richard
@vk2sky Yeah to you and other still commenting :) Thanks for the update, that clarifies a lot!
Have you tried to just open up Xcode and accept the license?
@laderbogen That was my issue, haha. Thanks! :)
@vk2sky :+1: Solved! Thank you
yeah! the same error! with @vixentael help, I fix errors.
I just had this same issue, and it seems Xcode had updated in the background and I haven't opened it to accept the new terms. Once I opened it & accepted the terms, I could successfully run gem install [gem_name]
I had the same issue earlier today. I had updated my xcode and had not agreed to the terms yet. Running sudo xcodebuild -license
and agreeing got my bundle working again.
Who is looking directly for "You have to install development tools first" and you did all steps (command line tools, xcode licence accept etc.). Try this:
I have to update rvm itself and force reinstall ruby:
http://www.fakingfantastic.com/2010/11/26/fixing-the-you-have-to-install-development-tools-first-error-with-nokogiri/
For example:
rvm update head
rvm --force install 1.9.3
@josescasanova this worked for me
thanks @masak2009 it worked with minor change: ruby 1.9.3 is no longer supported
rvm update head
rvm --force install 2.3.3
Thanks @gmale it worked for me :)
For future googlers, rehashing rbenv solved this issue for me.
rbenv rehash
Thanks! I solved my issue.
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
for more details check this link - https://stackoverflow.com/questions/17980759/xcode-select-active-developer-directory-error
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
for more details check this link - https://stackoverflow.com/questions/17980759/xcode-select-active-developer-directory-error
Thanks! It solved for me
I updated ruby, it was somewhat behind, then I was able to install cocoapods (and it got rid of some other gem errors I was having).
I was getting this error as well and resolved by installing with homebrew instead.
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
for more details check this link - https://stackoverflow.com/questions/17980759/xcode-select-active-developer-directory-error
This fixed my issue.
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer
for more details check this link - https://stackoverflow.com/questions/17980759/xcode-select-active-developer-directory-error
I solve my issue. Thanks!! 👍
i spent almost 3 days of work trying to fix this, but finally got it to work, here is all that you need to do
install brew -
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
when brew is installed, its git repository comes outdated, so you have to update it so you can install the latest version of the softwares you`ll need-
git -C $(brew --repo homebrew/core) checkout master
instead of installing by gem, use brew to install cocoapods, then overwrite the link in case it shows the error
(Error: The brew link
step did not complete successfully)
brew install cocoapods
brew link --overwrite cocoapods (just in case the brew link doesnt work at first)
this way you`ll have installed the latest version of cocoapods and you can verify it by using pod -v
i guess there is a way of doing this by using gem, but you'd need to fix Apple's broken by default products, and that's a lot of work
hope i helped
Most helpful comment
Did you by chance do
xcode-select --install
?I'm wondering if the "development tools" meant there was an issue with the xcode build system?