skip to Main Content

I have catalina OS 10.15.7 and XCode Version 12.4 (12D4e)
I am trying to install cocoapods using gem:

sudo gem install cocoapods

And I am getting this error:

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.

It has been a nightmare to resolve this.
I tried using brew install. Brew is able to install it. But the pod does not work. when I use simple commands like

pod init
or 
pod -v

I am getting this error:

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:1369:in `activate'
    11: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1387:in `activate_dependencies'
    10: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1387:in `each'
     9: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1405:in `block in activate_dependencies'
     8: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1369:in `activate'
     7: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1387:in `activate_dependencies'
     6: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1387:in `each'
     5: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1405:in `block in activate_dependencies'
     4: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1369:in `activate'
     3: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1387:in `activate_dependencies'
     2: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1387: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/dependency.rb:311:in `to_specs': Could not find 'minitest' (>= 5.1) among 39 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/pankajnafria/.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:1369:in `activate'
    11: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1387:in `activate_dependencies'
    10: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1387:in `each'
     9: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1405:in `block in activate_dependencies'
     8: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1369:in `activate'
     7: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1387:in `activate_dependencies'
     6: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1387:in `each'
     5: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1405:in `block in activate_dependencies'
     4: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1369:in `activate'
     3: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1387:in `activate_dependencies'
     2: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1387:in `each'
     1: from /Library/Ruby/Site/2.6.0/rubygems/specification.rb:1398:in `block in activate_dependencies'
/Library/Ruby/Site/2.6.0/rubygems/specification.rb:1401: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/pankajnafria/.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 

Appreciate any help in resolving this issue.

2

Answers


  1. I was able to resolve this issue by reinstalling Ruby/Rubygems and CocoaPods.

    First, I followed Moncef Belyamani’s thorough instructions for installing Ruby/Rubygems.

    Next, I ran several commands:

    gem install json
    gem install CFPropertyList
    gem pristine json --version 2.6.1
    

    Per suggestion from here:

    gem update --system 3.2.33
    

    And I reinstalled CocoaPods:

    brew uninstall cocoapods
    brew cleanup -s
    brew install cocoapods
    
    Login or Signup to reply.
  2. Open Terminal

    curl -L https://get.rvm.io | bash -s stable
    

    Then, close and reopen terminal

    rvm install ruby-3.1.1
    

    When finished, run:

    rvm use ruby-3.1.1
    

    And then:

    rvm --default use 3.1.1
    

    Next step, install cocoapods using:

    sudo gem install cocoapods
    

    For more info, check this [link].(https://developer.apple.com/forums/thread/697249)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search