安裝Cocoapods時候ERROR: While executing gem ... (Errno::EPERM)

OS X 10.11 安裝Cocoapods 出現問題的解決方法 
今天嘗試用 Cocoapods安裝個第三方庫.. 輸入pod install, 發現 command not find。 WTF!javascript

估計是升級10.11後Cocoapods被幹掉了。java

我輸入 sudo gem install cocoa pods 以後,出現以下問題:git

ERROR:  While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/xcodeproj
  • 1
  • 2

我估計是gem版本沒有更新。執行sudo gem update –system,又出現了錯誤github

ERROR:  While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/update_rubygems
  • 1
  • 2

Stackoverflow上找到了解決方法:xcode

由於知道gem版本過老的話也是不能成功下載cocoapods的,可是我如今又不能用sudo gem update –system來更新。後來我就直接去rubygems官網下載了最新的源碼進行了安裝。如今執行gem -v顯示版本是2.4.8。 
能夠看我另一篇文章,手動安裝gemruby

但是問題又來了,這個時候去執行sudo gem install cocoapods,仍是會出現上邊的錯誤。 
因此執行下邊:app

自定義GEM_HOME
$ mkdir -p $HOME/Software/ruby
$ export GEM_HOME=$HOME/Software/ruby
$ gem install cocoapods
[...] 1 gem installed $ export PATH=$PATH:$HOME/Software/ruby/bin $ pod --version 0.38.2
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

GEM_PATH與GEM_HOME 的區別:ide

1.GEM_PATH provides the locations (there may be several) where gems can be found. 
2.GEM_HOME is where gems will be installed (by default).(Therefore GEM_PATH should include GEM_HOME).ui

可是以後我pod install的時候又花式出錯url

[!] Unable to add a source with url `https://github.com/CocoaPods/Specs.git` named `master`. You can try adding it manually in `~/.cocoapods/repos` or via `pod repo add`.
  • 1
  • 2

我嘗試按提示的方法

pod repo add master https://github.com/CocoaPods/Specs.git
  • 1

然而仍是有錯..

[!] /usr/bin/git clone http://git.oschina.net/akuandev/Specs.git master xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
  • 1
  • 2
  • 3

最後的解決方法:

sudo xcode-select -switch /Applications/Xcode-beta.app/Contents/Developers
  • 1

後面的地址你能夠打開Xcode顯示包內容,找到那個文件夾拖到終端裏面比較不容易錯。

最後終於修成正果..

至於一開始輸入 sudo gem install cocoapods 沒反應須要修改成淘寶鏡像的問題,請百度Cocoapods參閱其它文章..

相關文章
相關標籤/搜索