0
Mac OS 10.15.7


ABCD-MBP:~ abcd$ which ruby
/usr/local/opt/ruby/bin/ruby

ABCD-MBP:~ abcd$ ruby -v
ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [x86_64-darwin19]

pod setup

Traceback (most recent call last):
    3: from /usr/local/bin/pod:22:in `<main>'
    2: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
    1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/dependency.rb:323:in `to_spec'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/dependency.rb:311:in `to_specs': Could not find 'cocoapods' (>= 0.a) among 48 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/abcd/.gem/ruby/2.6.0:/Library/Ruby/Gems/2.6.0:/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0', execute `gem env` for more information

I'm not getting why old version of ruby is getting referred here ?

With XCode > pod install is failing as old version of ruby is getting referred as well.

Traceback (most recent call last):
        3: from /usr/local/bin/pod:22:in `<main>'
        2: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
        1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/dependency.rb:323:in `to_spec'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/dependency.rb:311:in `to_specs': Could not find 'cocoapods' (>= 0.a) among 48 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/abcd/.gem/ruby/2.6.0:/Library/Ruby/Gems/2.6.0:/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0', execute `gem env` for more information

I tried different solutions proposed in SO but couldn't get this fixed

  • uninstall all gems and install again
  • uninstall pod and install again
vikramvi
  • 3,312
  • 10
  • 45
  • 68
  • Cocoapods [install documentation](https://cocoapods.org) says "We recommend you use the default ruby", which is the one in `/usr/bin/ruby`. I'm not a cocoapods user, so I don't know if that's wired into the `pods` command or can be overridden by doing the `gem install cocoapods` command using `/usr/local/opt/ruby/bin/gem`. – pjs Jul 10 '21 at 00:50

1 Answers1

0

This issue happens when default Mac has got different ruby version that one you have installed

I could solve this by installing same ruby version as Mac OS ruby framework. Remove all gems, reinstall pod again.

References

  1. https://github.com/CocoaPods/CocoaPods/issues/10246#issuecomment-761719446

  2. https://superuser.com/questions/340490/how-to-install-and-use-different-versions-of-ruby

  3. https://rvm.io/rvm/install

  4. https://jeffreymorgan.io/articles/ruby-on-macos-with-rvm/

  5. https://github.com/rvm/rvm/issues/4215

  6. Uninstall all installed gems, in OSX?

  7. homebrew uninstall ruby

  8. https://rvm.io/rubies/default

I wonder what kind of fun Apple engineers get to make pod + ruby such complex thing to fix :)

vikramvi
  • 3,312
  • 10
  • 45
  • 68