Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Current CocoaPods should be installable on Mojave without dependency upgrades #9641

Closed
1 task done
mferber opened this issue Mar 24, 2020 · 28 comments
Closed
1 task done
Labels
help wanted Help from new or existing contributors would be greatly appreciated! s1:awaiting input Waiting for input from the original author

Comments

@mferber
Copy link

mferber commented Mar 24, 2020

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:

  • If possible, revert the Ruby dependencies that created this problem.
  • If possible, change the gem installation to output a helpful response with instructions when this failure occurs (I don't know if the output from gem install can be controlled).
  • At an absolute minimum, please add a prominent notice to the installation instructions on the website indicating that the installation may not work on Mojave and how to fix it (e.g., install rvm and Ruby 2.6.x).

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.6

What 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

@dnkoutso
Copy link
Contributor

Hey there and thanks for the issue. I apologize if any of the other issues have come off "brush-offy" (is that even a word?). Anyway, intention is not to ignore people or their efforts but overall CocoaPods gets a ton of issues around environment setup or more or less "irrelevant" to CocoaPods issues.

Having said that, if someone is installing CocoaPods and its failing to do so I can see a reason to file an issue here...

Back to this issue. I have Mojave 10.14.6 and I install CocoaPods and different versions of Ruby almost daily. I do not hit this issue so I kindly ask you if possible to provide steps to reproduce.

@dnkoutso dnkoutso added the s1:awaiting input Waiting for input from the original author label Mar 24, 2020
@mferber
Copy link
Author

mferber commented Mar 24, 2020

@dnkoutso Thank you for the thoughtful response! I was really hoping for, if not a fix, at least a clearer understanding of why it wasn't being addressed. "Can't reproduce" is a far more interesting angle.

It's not completely impossible that something I did to my environment in the distant past triggered this behavior, but I've installed and upgraded CocoaPods a number of times over the years and never had trouble before. I think the best way for me to provide steps is to uninstall rvm and the Ruby version, see if I reproduce the problem, and provide a console log if so. I'll post that shortly if I'm successful.

@stale stale bot removed the s1:awaiting input Waiting for input from the original author label Mar 24, 2020
@dnkoutso
Copy link
Contributor

Thanks again! You are very right, somewhere along all the similar issues filed I may have asked for steps before and maybe a prior issue was closed due to being unable to reproduce.

I will keep this open of course and hopefully we will get to the bottom of this.

@dnkoutso
Copy link
Contributor

Keep in mind we automatically close issues via a bot if it becomes inactive.

@mferber
Copy link
Author

mferber commented Mar 24, 2020

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...]

@dnkoutso
Copy link
Contributor

dnkoutso commented Mar 24, 2020

From the last part it seems it went through:

/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)

which was your system ruby not 2.6.5 even though the stacktrace includes traces of Ruby 2.6.5...

@mferber
Copy link
Author

mferber commented Mar 24, 2020

Right, that's what I said at the beginning of my note. :-) I may be close to a fix for that piece — best ignore that part for now. (UPDATE: not sure exactly what I did right but it's running now.)

@dnkoutso
Copy link
Contributor

nice

@mferber
Copy link
Author

mferber commented Mar 24, 2020

@dnkoutso Let me know if that transcript provides enough in the way of repro instructions. I'm not sure what I can add to it, so I hope so!

@monsieurPaon
Copy link

Same issue with exactly the same env.

@monsieurPaon
Copy link

monsieurPaon commented Mar 24, 2020

shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

/Library/Ruby/Gems/2.3.0/gems/cocoapods-1.9.1/lib/cocoapods/executable.rb:97:in `expand_path': No such file or directory - getcwd (Errno::ENOENT)
        from /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.9.1/lib/cocoapods/executable.rb:97:in `block in which'
        from /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.9.1/lib/cocoapods/executable.rb:96:in `each'
        from /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.9.1/lib/cocoapods/executable.rb:96:in `which'
        from /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.9.1/lib/cocoapods/executable.rb:117:in `which!'
        from /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.9.1/lib/cocoapods/executable.rb:143:in `capture_command'
        from /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.9.1/lib/cocoapods/command.rb:116:in `git_version'
        from /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.9.1/lib/cocoapods/command.rb:130:in `verify_minimum_git_version!'
        from /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.9.1/lib/cocoapods/command.rb:49:in `run'
        from /Library/Ruby/Gems/2.3.0/gems/cocoapods-1.9.1/bin/pod:55:in `<top (required)>'
        from /usr/local/bin/pod:22:in `load'
        from /usr/local/bin/pod:22:in `<main>'

@dnkoutso
Copy link
Contributor

Its certainly more info than other reports. Unfortunately I cant tell again what is wrong with CocoaPods per se except that a downstream dependency somehow does not install on Ruby 2.3.x.

I'd appreciate anyone who can help here.

@dnkoutso dnkoutso added the help wanted Help from new or existing contributors would be greatly appreciated! label Mar 25, 2020
@vokal-isaac
Copy link

It looks like cocoapods-core added typhoeus in 1.9.x and typhoeus depends on ethon, which depends on ffi, which is causing the error. None of typhoeus, ethon, or ffi were dependencies of cocoapods 1.8.4.

@orta
Copy link
Member

orta commented Mar 25, 2020

In ffi/ffi#706 they recommend using ffi 1.9.17 as a workaround, I don't know the dependency tree but perhaps that version can be locked in cocoapods-core?

@vokal-isaac
Copy link

@orta It's possible there's a config issue on my end, but I get basically the same error with 1.9.17:

$ sudo gem install ffi -v 1.9.17
Building native extensions.  This could take a while...
ERROR:  Error installing ffi:
	ERROR: Failed to build gem native extension.

    current directory: /Library/Ruby/Gems/2.3.0/gems/ffi-1.9.17/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20200325-55209-lxehr8.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.9.17 for inspection.
Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-18/2.3.0/ffi-1.9.17/gem_make.out
$

@amorde
Copy link
Member

amorde commented Apr 20, 2020

CocoaPods/Core#580 is the PR that added this dependency, it is possible to undo this but would take some work and also undo a lot of improvements that were made

@TylerADavis
Copy link

TylerADavis commented Apr 25, 2020

Is there a recommended workaround for this issue?

I don't have much experience with ruby, so I don't know what the best way to upgrade ruby without breaking things would be. I'd really appreciate a clear set of commands I could execute.

I'd tried using rvm a few weeks back, but whatever I'd done didn't work.

I'm on macOS Catalina and ruby --version shows ruby 2.6.0p0 (2018-12-25 revision 66547)

@laoman
Copy link

laoman commented Apr 26, 2020

what @mferber suggested works fine, cheers.

@mferber
Copy link
Author

mferber commented Apr 26, 2020

@TylerADavis If you haven't already found it, I documented a transcript upthread of what did and didn't work for me, which ought to serve as a guide to the workaround. See specifically the part beginning "Install rvm." #9641 (comment)

@mferber
Copy link
Author

mferber commented Apr 26, 2020

(Unfortunately, you'll see that after I'd successfully installed CocoaPods, running it failed at first due to a bad ruby module search path, and I got it working without identifying exactly what had fixed the problem. If that happens to you, I'd recommend restarting the terminal and maybe even rebooting your computer, then running the "rvm use" command again, to make sure the paths are all fully reinitialized, but I can't promise that will work. Hope this is of some help!)

@TylerADavis
Copy link

Thanks @mferber , I'd missed that originally.

I followed the steps you took, but I'm still unable to build cocoapods. It looks like I'm using the same version of ruby (2.6.5, though I also tried 2.6.6) and lib ffi (1.12.2) as you, so I'm not sure where the issue is coming from. In the error messages it looks like the paths are messed up as it's still mentioning 2.6.0? This is despite restarting both the terminal and rebooting my computer.

Is there some step I'm missing to make the install actually use the version of ruby from RVM?

tyler@s ~ % rvm use ruby-2.6.5
Using /Users/tyler/.rvm/gems/ruby-2.6.5
tyler@s- ~ % which ruby
/Users/tyler/.rvm/rubies/ruby-2.6.5/bin/ruby
tyler@s ~ % ruby --version
ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin19]
tyler@s ~ % 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: /Users/tyler/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/ffi-1.12.2/ext/ffi_c
/Users/tyler/.rvm/rubies/ruby-2.6.5/bin/ruby -I /Users/tyler/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0 -r ./siteconf20200426-1485-18l80cq.rb extconf.rb
checking for ffi.h... no
checking for ffi.h in /usr/local/include,/usr/include/ffi... no
checking for shlwapi.h... no
checking for rb_thread_call_without_gvl()... yes
checking for ruby_native_thread_p()... yes
checking for ruby_thread_has_gvl_p()... yes
creating extconf.h
creating Makefile

current directory: /Users/tyler/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/ffi-1.12.2/ext/ffi_c
make "DESTDIR=" clean

current directory: /Users/tyler/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/ffi-1.12.2/ext/ffi_c
make "DESTDIR="
Configuring libffi
configure: error: in `/Users/tyler/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/ffi-1.12.2/ext/ffi_c/libffi-x86_64-darwin19':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details
make: *** ["/Users/tyler/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/ffi-1.12.2/ext/ffi_c/libffi-x86_64-darwin19"/.libs/libffi_convenience.a] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/tyler/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/gems/ffi-1.12.2 for inspection.
Results logged to /Users/tyler/.rvm/rubies/ruby-2.6.5/lib/ruby/gems/2.6.0/extensions/x86_64-darwin-19/2.6.0/ffi-1.12.2/gem_make.out

@mferber
Copy link
Author

mferber commented Apr 26, 2020

@TylerADavis It's trying and failing to build the Mac-native part of the gem that Cocoapods is depending on. We're getting slightly outside of my area of confidence, but based on some quick googling, it sounds like the first thing to check is that your Xcode is fully up to date, and if that doesn't work, then you might need to (re)install the developer command line tools (xcode-select --install in the terminal, then confirm when prompted). Again I'd try rebooting after doing either of those things just to make sure everything is clean.

If those don't work, which sounds like a real possibility, I'm probably not going to be able to help much without doing some real research. Maybe someone from the dev team will be able to chime in with something more solid, I hope. Good luck!!

@TylerADavis
Copy link

I was able to work around this by installing the cocoapods desktop app:

https://cocoapods.org/app

@mferber
Copy link
Author

mferber commented Apr 27, 2020

That's fantastic, I had no idea that existed!

@TylerADavis
Copy link

It turns out the app is actually pretty out of date, so I did the following to get cocoa pods to work

  1. brew install cocoapods
  2. At this point pod install was failing, and I had to do rvm use system (I'd previously installed a few different versions to try and fix things up above). After this everything worked without issue.

@stale
Copy link

stale bot commented Jul 27, 2020

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

@stale stale bot added the s1:awaiting input Waiting for input from the original author label Jul 27, 2020
@stale
Copy link

stale bot commented Aug 3, 2020

This issue will be auto-closed because there hasn't been any activity for a few months. Feel free to open a new one if you still experience this problem 👍

@stale stale bot closed this as completed Aug 3, 2020
@Alek-Ruseski
Copy link

@mferber 's step by step guide helped me out to install cocoapods (I needed it for my Unity project).

To not make this just a thank you reply, I will contribute by adding that you can do the same procedure by using Homebrew as well (for the step of installing ruby). This stackoverflow answer is quite useful for that purpose:
https://stackoverflow.com/a/62706706/4318033

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Help from new or existing contributors would be greatly appreciated! s1:awaiting input Waiting for input from the original author
Projects
None yet
Development

No branches or pull requests

9 participants