SolvedCocoaPods Current CocoaPods should be installable on Mojave without dependency upgrades
โ๏ธAccepted Answer
Here's an annotated transcript of my console session reproducing the problem.
I've also discovered that even though I've now built CocoaPods correctly, I can't run it. I've just begun to look at that, but it looks like it's still using a search path that includes the system Ruby. That's at the end of this transcript.
Initial environment โ note using system Ruby, v2.3.7:
[1 12:49 ~/] where ruby
/usr/bin/ruby
[2 12:49 ~/] which ruby
/usr/bin/ruby
[3 12:49 ~/] ruby --version
ruby 2.3.7p456 (2018-03-28 revision 63024) [universal.x86_64-darwin18]
For good measure, although I don't think this is important:
[4 12:49 ~/] xcode-select -p
/Applications/Xcode.app/Contents/Developer
[5 12:49 ~/] xcode-select -v
xcode-select version 2354.
Initial attempt to install Cocoapods fails due to missing header files:
[6 12:50 ~/] sudo gem install cocoapods
Password:
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.3.0/gems/ffi-1.12.2/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20200324-65620-13stqp2.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/include/ruby.h
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/ffi-1.12.2 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.12.2/gem_make.out
Install rvm and use it to install Ruby 2.6.x (as suggested on StackOverflow):
[7 12:50 ~/] curl -sSL https://get.rvm.io | bash
Downloading https://github.com/rvm/rvm/archive/master.tar.gz
Installing RVM to /Users/matthias/.rvm/
RVM PATH line found in /Users/matthias/.mkshrc /Users/matthias/.profile /Users/matthias/.bashrc /Users/matthias/.zshenv.
RVM sourcing line found in /Users/matthias/.profile /Users/matthias/.bash_profile /Users/matthias/.zlogin.
Installation of RVM in /Users/matthias/.rvm/ is almost complete:
* To start using RVM you need to run `source /Users/matthias/.rvm/scripts/rvm`
in all your open shell windows, in rare cases you need to reopen all shell windows.
Thanks for installing RVM ๐
Please consider donating to our open collective to help us maintain RVM.
๐ Donate: https://opencollective.com/rvm/donate
[8 12:52 ~/] which rvm
/Users/matthias/.rvm/bin/rvm
[10 12:52 ~/] . ~/.rvm/scripts/rvm
. ~/.rvm/scripts/rvm
[11 12:52 ~/] echo $PATH
[...snip...]:/Users/[USERNAME]/.rvm/bin
[12 12:52 ~/] rvm install 2.6
Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.14/x86_64/ruby-2.6.5.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Certificates bundle '/usr/local/etc/openssl@1.1/cert.pem' is already up to date.
Requirements installation successful.
Installing Ruby from source to: /Users/matthias/.rvm/rubies/ruby-2.6.5, this may take a while depending on your cpu(s)...
ruby-2.6.5 - #downloading ruby-2.6.5, this may take a while depending on your connection...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 13.4M 100 13.4M 0 0 4498k 0 0:00:03 0:00:03 --:--:-- 4499k
ruby-2.6.5 - #extracting ruby-2.6.5 to /Users/matthias/.rvm/src/ruby-2.6.5 - please wait
ruby-2.6.5 - #configuring - please wait
ruby-2.6.5 - #post-configuration - please wait
ruby-2.6.5 - #compiling - please wait
ruby-2.6.5 - #installing - please wait
ruby-2.6.5 - #making binaries executable - please wait
ruby-2.6.5 - #downloading rubygems-3.0.8
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 867k 100 867k 0 0 1779k 0 --:--:-- --:--:-- --:--:-- 1777k
No checksum for downloaded archive, recording checksum in user configuration.
ruby-2.6.5 - #extracting rubygems-3.0.8 - please wait
ruby-2.6.5 - #removing old rubygems - please wait
ruby-2.6.5 - #installing rubygems-3.0.8 - please wait
ruby-2.6.5 - #gemset created /Users/matthias/.rvm/gems/ruby-2.6.5@global
ruby-2.6.5 - #importing gemset /Users/matthias/.rvm/gemsets/global.gems - please wait
ruby-2.6.5 - #generating global wrappers - please wait
ruby-2.6.5 - #gemset created /Users/matthias/.rvm/gems/ruby-2.6.5
ruby-2.6.5 - #importing gemsetfile /Users/matthias/.rvm/gemsets/default.gems evaluated to empty gem list
ruby-2.6.5 - #generating default wrappers - please wait
ruby-2.6.5 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-2.6.5 - #complete
Ruby was built without documentation, to build it run: rvm docs generate-ri
[13 12:56 ~/] rvm use ruby-2.6.5
Using /Users/matthias/.rvm/gems/ruby-2.6.5
Confirm using Ruby 2.6.5:
[14 12:57 ~/] where ruby
/Users/matthias/.rvm/rubies/ruby-2.6.5/bin/ruby
/usr/bin/ruby
[15 12:57 ~/] which ruby
/Users/matthias/.rvm/rubies/ruby-2.6.5/bin/ruby
CocoaPods installation is now successful:
[16 12:57 ~/] sudo gem install cocoapods
Password:
Fetching tzinfo-1.2.6.gem
Fetching concurrent-ruby-1.1.6.gem
[...snip...]
Fetching ffi-1.12.2.gem
[...snip...]
33 gems installed
Running pod
still fails: [UPDATE: this piece is fixed]
[24 01:05 ~/] pod
Ignoring executable-hooks-1.6.0 because its extensions are not built. Try: gem pristine executable-hooks --version 1.6.0
Ignoring ffi-1.12.2 because its extensions are not built. Try: gem pristine ffi --version 1.12.2
Ignoring gem-wrappers-1.4.0 because its extensions are not built. Try: gem pristine gem-wrappers --version 1.4.0
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': incompatible library version - /Users/matthias/.rvm/gems/ruby-2.6.5@global/gems/ffi-1.12.2/lib/ffi_c.bundle (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/matthias/.rvm/gems/ruby-2.6.5@global/gems/ffi-1.12.2/lib/ffi.rb:6:in `rescue in <top (required)>'
from /Users/matthias/.rvm/gems/ruby-2.6.5@global/gems/ffi-1.12.2/lib/ffi.rb:3:in `<top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
[..snip...]
Other Answers:
It turns out the app is actually pretty out of date, so I did the following to get cocoa pods to work
brew install cocoapods
- At this point
pod install
was failing, and I had to dorvm use system
(I'd previously installed a few different versions to try and fix things up above). After this everything worked without issue.
Several tickets related to this problem have been closed as having to do with the user's build environment rather than the CocoaPods install itself (here's one closed yesterday). That would be reasonable if this was an extremely old OS or the user had messed it up, but we're talking about a perfectly normal Mojave install. Mojave is only one major version behind.
CocoaPods installation should not fail on an unmodified Mojave installation. Please reconsider the "not our problem" attitude. CocoaPods should be usable without difficulty on all macOS platforms that are in wide usage. Leaving high barriers for users unaddressed is bad for CocoaPods. I beg you to consider at least one of the following options:
gem install
can be controlled).From the perspective I'm coming from, the current approach appears as a rather shocking disregard for CocoaPods's usability. I really beg you to think again about addressing this problem. It's clearly common, and it will only be to CocoaPods's benefit to give users an assist here.
Report
What did you do?
sudo gem install cocoapods
on macOS Mojave 10.14.6What did you expect to happen?
Expected CocoaPods to install cleanly.
What happened instead?
Ruby errors: "Failed to build gem native extension." To resolve the problem I had to search through CocoaPods issues and StackOverflow and try to evaluate a number of different suggestions for solving the problem, most of which were not solidly within my current expertise (I haven't worked in Ruby for several years). Ultimately I installed rvm and Ruby 2.6.3, and that worked, but from the available sources, I didn't have great confidence that it was the best solution.
CocoaPods Environment
n/a