Unable to install Cocoapods with RubyGem 2.7.1

My Cocoapods do not work, so I ran the following command:

  • run this bash script to remove all matching stones:

    for i in $( gem list --local --no-version | grep cocoapods ); do sudo gem uninstall $i; done 
  • delete ~ / .cocoapods to remove podspecs cache .:

     rm -rf ~/.cocoapods/ 
  • update rubygem:

     sudo gem update --system 
  • reinstall cocoapods:

     sudo gem install cocoapods 

Then I got a file permission error message in step 3 and step 4:

Step3 error message:
...
...
Installation of documentation for updating rubygems in 0 seconds is completed

Installing RubyGems 2.7.1
ERROR: When executing gem ... (Errno :: EPERM)
Operation not allowed @rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/gem

Step4 error message:
Extract: cocoapods-core-1.3.1.gem (100%)
Cocoapods-core-1.3.1 installed successfully
Extract: cocoapods-deintegrate-1.0.1.gem (100%)
Successfully installed cocoapods-deintegrate-1.0.1
Getting: cocoapods-downloader-1.1.3.gem (100%)
Cocoapods-downloader-1.1.3 installed successfully
Extract: cocoapods-plugins-1.0.0.gem (100%)
Successfully installed cocoapods-plugins-1.0.0
Extract: cocoapods-search-1.0.0.gem (100%)
Cocoapods-search-1.0.0 installed successfully
Getting: cocoapods-stats-1.0.0.gem (100%)
Cocoapods-stats-1.0.0 installed successfully
Extract: cocoapods-trunk-1.3.0.gem (100%)
Cocoapods-trunk-1.3.0 installed successfully
Getting: cocoapods-try-1.1.0.gem (100%)
Cocoapods-try-1.1.0 installed successfully
ERROR: when executing gem ... (Gem :: FilePermissionError) You do not have write permissions for the / usr / bin directory.

I have limited knowledge of the Linux / OSX system file and donโ€™t know what was wrong.

Here is the information about my computer:

  • OS:

    macOS High Sierra 10.13.1

  • Xcode:

    Version 9.0.1 (9A1004)
    I also have Xcode 7.3.1 renamed from Xcode_7 to the application folder

  • The path to the environment:

     echo $PATH 

    /Library/Frameworks/Python.framework/Versions/3.4/bin:
    / Usr / local / bin:
    / Usr / bin:
    /Ben:
    / USR / SBIN:
    / SBIN:
    / Wholesale / X11 / bin:
    /Applications/Server.app/Contents/ServerRoot/usr/bin:
    /Applications/Server.app/Contents/ServerRoot/usr/sbin

  • Homebrew:

     brew --version 

    Homebrew 1.3.6
    Homebrew / homebrew-core (git version 985b, last fix 2017-11-07)

     brew list 

    cmake libxml2 ninja pkg-config readline wget gdbm libyaml openssl python3 sqlite xz

  • RubyGems:

     gem --version 

    2.7.1

     gem list 

    * LOCAL GEMS *
    activesupport (5.1.4, 4.2.10)
    bigdecimal (1.3.2, default: 1.2.8)
    CFPropertyList (2.3.5, 2.2.8)
    claide (1.0.2)
    color2 (3.1.2)
    parallel-ruby (1.0.5)
    did_you_mean (1.0.0)
    escape (0.0.4)
    fourflusher (2.0.1)
    fuzzy_match (2.1.0, 2.0.4)
    gh_inspector (1.0.3)
    i18n (0.9)
    io-console (0.4.6, default: 0.4.5)
    json (2.1.0, default value: 1.8.3)
    libxml-ruby (3.0.0, 2.9.0)
    mini_portile2 (2.3.0)
    minitest (5.10.3)
    molinillo (0.6.4, 0.5.7)
    nanaimo (0.2.3)
    nap (1.1.0)
    net-telnet (0.1.1)
    netrc (0.11.0)
    nokogiri (1.5.6)
    power_assert (1.1.1)
    psych (2.2.4, default: 2.1.0)
    rake (12.2.1, 10.4.2)
    rdoc (5.1.0, default: 4.2.1)
    ruby macho (1.1.0)
    rubygems-update (2.7.1)
    sqlite3 (1.3.11)
    test facility (3.2.6)
    thread_safe (0.3.6)
    tzinfo (1.2.4)
    xcodeproj (1.5.3)

+5
source share
2 answers

This worked for me.

Also there was an error reinstalling Ruby when running sudo gem update -system

 ERROR: While executing gem ... (Errno::EPERM) Operation not permitted @ rb_sysopen - /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/gem 

Then I tried to run the same command again (sudo gem update - system) and got the latest version already installed . Done.

Instead of starting

 sudo gem install cocoapods 

to try

 sudo gem install -n /usr/local/bin cocoapods 

Which finished working for me! Did not clear previous cocoapods with a bash script, as you did in step 1, but should not make any difference as you reinstall.

+15
source

I think Hyalmarโ€™s answer really works. However, I used Homebrew to install Ruby, and everything works fine for me. Just enter:

 brew install ruby 

in the terminal.

+2
source

Source: https://habr.com/ru/post/1273197/


All Articles