2017-11-08 18 views
5
 

My Cocoapods did not work, therefore I did the following command: 

1. run this bash script to remove all the relevant gems: 
    for i in $(gem list --local --no-version | grep cocoapods); 
    do 
     sudo gem uninstall $i; 
    done 

2. delete ~/.cocoapods to remove the cache of podspecs.: 
    rm -rf ~/.cocoapods/ 

3. update rubygem: 
    sudo gem update --system 

4. reinstall cocoapods: 
    sudo gem install cocoapods 

Then I got file permission deny error message in Step3 and Step 4: 

Step3 error message: 
    ... 
    ... 
    Done installing documentation for rubygems-update after 0 seconds 
    Installing RubyGems 2.7.1 
    ERROR: While executing gem ... (Errno::EPERM) 
     Operation not permitted @ rb_sysopen - 
    /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/gem 

Step4 error message: 
    Fetching: cocoapods-core-1.3.1.gem (100%) 
    Successfully installed cocoapods-core-1.3.1 
    Fetching: cocoapods-deintegrate-1.0.1.gem (100%) 
    Successfully installed cocoapods-deintegrate-1.0.1 
    Fetching: cocoapods-downloader-1.1.3.gem (100%) 
    Successfully installed cocoapods-downloader-1.1.3 
    Fetching: cocoapods-plugins-1.0.0.gem (100%) 
    Successfully installed cocoapods-plugins-1.0.0 
    Fetching: cocoapods-search-1.0.0.gem (100%) 
    Successfully installed cocoapods-search-1.0.0 
    Fetching: cocoapods-stats-1.0.0.gem (100%) 
    Successfully installed cocoapods-stats-1.0.0 
    Fetching: cocoapods-trunk-1.3.0.gem (100%) 
    Successfully installed cocoapods-trunk-1.3.0 
    Fetching: cocoapods-try-1.1.0.gem (100%) 
    Successfully installed cocoapods-try-1.1.0 
    ERROR: While executing gem ... (Gem::FilePermissionError) 
     You don't have write permissions for the /usr/bin directory. 

I have limited knowledge about Linux/OSX file sysem, and do not know what was wrong. 

Any help would be appreciate. 

Here are information about my computer: 

1. OS: 
    macOS High Sierra 10.13.1 

2. Xcode: 
    Version 9.0.1 (9A1004) 
    I also have XCode 7.3.1 renamed as Xcode_7 in the Applications Folder 

3. Environment path: 
    echo $PATH 
    /Library/Frameworks/Python.framework/Versions/3.4/bin: 
    /usr/local/bin: 
    /usr/bin: 
    /bin: 
    /usr/sbin: 
    /sbin: 
    /opt/X11/bin: 
    /Applications/Server.app/Contents/ServerRoot/usr/bin: 
    /Applications/Server.app/Contents/ServerRoot/usr/sbin 

4. Homebrew: 
    brew --version 
    Homebrew 1.3.6 
    Homebrew/homebrew-core (git revision 985b; last commit 2017-11-07) 

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

5. 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) 
    colored2 (3.1.2) 
    concurrent-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.1) 
    io-console (0.4.6, default: 0.4.5) 
    json (2.1.0, default: 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-unit (3.2.6) 
    thread_safe (0.3.6) 
    tzinfo (1.2.4) 
    xcodeproj (1.5.3)
+0

여기에 같은 문제가 있습니다. – Hjalmar

답변

13

이것은 결국 저에게 효과적이었습니다.

는 또한 --system

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

그때 같은 명령을 execure하려고 루비가 sudo는 보석 업데이트를 실행 오류를 다시 설치 얻었다 (sudo는 보석 업데이트 --system)는 다시 있어 최신 버전이 이미 설치되어 있습니다. 끝난. 대신

sudo gem install cocoapods 

을 실행

나를 위해 일하는 결국

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

을 시도! 1 단계에서했던 것처럼 이전 코코아포드를 bash 스크립트로 지우지 않았지만 다시 설치할 때 차이를 만들어서는 안됩니다.

+0

은 나를 위해 일했습니다. –

+0

nokogiri와 동일한 기능을합니다 : sudo gem install nokogiri -v '1.8.2'-n/usr/local/bin' 감사합니다! –

1

나는 Hjalmar의 답변이 효과가 있다고 생각합니다. 그러나 나는 Ruby를 설치하기 위해 Homebrew를 사용하고 결국 모든 것이 잘 돌아 간다. 단지 다음을 입력하십시오 :

brew install ruby 

터미널에 입력하십시오.

+0

양조 버전을 사용하려면'brew link --overwrite ruby'를 실행해야 할 수도 있습니다. – emrahgunduz