24

I m trying to install Pod on my mac os (os version is big sure), and I m using Xcode 13.1

I m trying to install Pod with this command from terminal:

sudo pod install

then the system ask me password, after that I can see this error in terminal line:

Traceback (most recent call last):
    16: from /usr/local/Cellar/cocoapods/1.11.2_1/libexec/bin/pod:23:in `<main>'
    15: from /Library/Ruby/Site/2.6.0/rubygems.rb:285:in `activate_bin_path'
    14: from /Library/Ruby/Site/2.6.0/rubygems.rb:285:in `synchronize'
    13: from /Library/Ruby/Site/2.6.0/rubygems.rb:286:in `block in activate_bin_path'
    12: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1370:in `activate'
    11: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1388:in `activate_dependencies'
    10: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1388:in `each'
     9: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1406:in `block in activate_dependencies'
     8: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1370:in `activate'
     7: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1388:in `activate_dependencies'
     6: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1388:in `each'
     5: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1406:in `block in activate_dependencies'
     4: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1370:in `activate'
     3: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1388:in `activate_dependencies'
     2: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1388:in `each'
     1: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1400:in `block in activate_dependencies'
/Library/Ruby/Site/2.6.0/rubygems/dependency.rb:311:in `to_specs': Could not find 'minitest' (>= 5.1) among 39 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/michelecastriotta/.local/share/gem/ruby/2.6.0:/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0:/usr/local/Cellar/cocoapods/1.11.2_1/libexec' , execute `gem env` for more information
    16: from /usr/local/Cellar/cocoapods/1.11.2_1/libexec/bin/pod:23:in `<main>'
    15: from /Library/Ruby/Site/2.6.0/rubygems.rb:285:in `activate_bin_path'
    14: from /Library/Ruby/Site/2.6.0/rubygems.rb:285:in `synchronize'
    13: from /Library/Ruby/Site/2.6.0/rubygems.rb:286:in `block in activate_bin_path'
    12: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1370:in `activate'
    11: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1388:in `activate_dependencies'
    10: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1388:in `each'
     9: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1406:in `block in activate_dependencies'
     8: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1370:in `activate'
     7: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1388:in `activate_dependencies'
     6: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1388:in `each'
     5: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1406:in `block in activate_dependencies'
     4: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1370:in `activate'
     3: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1388:in `activate_dependencies'
     2: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1388:in `each'
     1: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1399:in `block in activate_dependencies'
/Library/Ruby/Site/2.6.0/rubygems/specification.rb:1402:in `rescue in block in activate_dependencies': Could not find 'minitest' (>= 5.1) among 39 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/michelecastriotta/.local/share/gem/ruby/2.6.0:/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0:/usr/local/Cellar/cocoapods/1.11.2_1/libexec' at: /usr/local/Cellar/cocoapods/1.11.2_1/libexec/specifications/activesupport-6.1.4.1.gemspec, execute `gem env` for more information

how can I do to install pod on my mac?

bircastri
  • 2,169
  • 13
  • 50
  • 119
  • Did you checked https://stackoverflow.com/questions/68466544/could-not-find-minitest-5-1-among-42-total-gems-gemmissingspecerror and the solution of the author in the comment? Else, do you need to use Gem/Ruby, or can you do it with Homebrew? Also, CoocoaPods.app was also able to install CocoaPods if I remember (did it a long time ago), might worth a shot too. – Larme Jan 07 '22 at 06:44
  • See also https://stackoverflow.com/questions/70537795/unable-to-install-cocoapods-on-catalina – rmtheis Jan 10 '22 at 15:21
  • I find a solution here, help me save lot of time https://stackoverflow.com/a/62706706/11101498 – Phạm Ân Feb 24 '22 at 08:29
  • https://stackoverflow.com/a/62706706/11101498 found a solution here! This solution work for me – Phạm Ân Feb 24 '22 at 08:34

2 Answers2

44

I faced a similar issue, by default system ruby version is being used, we need to bypass it and then continue with cocoa pods.

Install ruby using homebrew

brew install ruby

By default, binaries installed by gem will be placed into: /usr/local/lib/ruby/gems/2.7.0/bin

You may want to add this to your PATH.

ruby is keg-only, which means it was not symlinked into /usr/local, because macOS already provides this software and installing another version in parallel can cause all kinds of trouble.

If you need to have ruby first in your PATH run (and replace user_name with your username):

echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> /Users/user_name/.bash_profile

For compilers to find ruby you may need to set:

 export LDFLAGS="-L/usr/local/opt/ruby/lib"
 export CPPFLAGS="-I/usr/local/opt/ruby/include"

Follow the instructions to set PATH. Replace user_name with your username

echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> /Users/user_name/.bash_profile
echo 'export LDFLAGS="-L/usr/local/opt/ruby/lib"' >> ~/.bash_profile
echo 'export CPPFLAGS="-I/usr/local/opt/ruby/include"' >> ~/.bash_profile

source ~/.bash_profile

Check your path

ruby -v
ruby 3.1.1p18 (2022-02-18 revision 53f5fc4236) [x86_64-darwin20]
user@MacBook-Air ios % which ruby
/usr/local/opt/ruby/bin/ruby

That's it, ruby version is all set Install cocoa pods then you are good to go

sudo gem install -n /usr/local/bin cocoapods
turingtested
  • 6,356
  • 7
  • 32
  • 47
Vicky Salunkhe
  • 9,869
  • 6
  • 42
  • 59
  • 1
    You are awesome.. I was facing same issue after installing new Mac OS 12.6.5, Your nice answer helped me... I was struggling from last 4-5 hrs Appreciate you.. Thank you so much.... – Ash Jan 30 '23 at 22:04
3

just try reinstalling the missing gem minitest mentioned in that error message like this:

gem install minitest -v 5.1.0

this should solve your current problem but you may have more errors for other missing gems. in that case, check your message for things like Could not find 'minitest' (>= 5.1) and try installing them.

if you are overwhelmed by too many of these missing gem errors, try uninstalling cocopods and then re-installing it.

Yılmaz Durmaz
  • 2,374
  • 12
  • 26
  • 2
    Getting ERROR: While executing gem ... (Gem::FilePermissionError) You don't have write permissions for the /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/gems/2.6.0 directory. I have installed gem using brew, as I was facing this issue while installing through gem – Deepa Suryawanshi Jan 18 '22 at 04:27
  • @DeepaSuryawanshi did you try the commands with "sudo" in front? most libraries are installed into system folders. if the write error comes even with sudo, then maybe a disk error you have. – Yılmaz Durmaz Jan 18 '22 at 08:29
  • I was able to fix this issue by installing ruby through brew, not using the default system one.. and then I installed cocoapods using "sudo gem install cocoapods" The link I referred: [link] (https://mac.install.guide/ruby/13.html) – Deepa Suryawanshi Jan 19 '22 at 09:26
  • 2
    @DeepaSuryawanshi ok, so we are in a year where libraries do breaking changes and library managers fetch those incompatible ones if you don't supply version during installs. you probably fetched cocoapods for ruby 3, but your system had 2.6, and now you should have ruby 3. please provide your own posted answer telling what you had to do, and what current version you ended up. also give an upvote if I helped a bit. – Yılmaz Durmaz Jan 19 '22 at 09:39
  • Okay.. So I installed ruby from brew and its version is "ruby 3.0.3p157". Previously when I used system ruby, that time I was facing the above issue. – Deepa Suryawanshi Jan 20 '22 at 15:26
  • If you're having an error , try using `sudo gem install minitest -v 5.1.0` – Philip E Jun 13 '23 at 19:12