安裝Pod時提示ERROR: While executing gem ... (Errno::EPERM) Operation not permitted - /usr/bin/pod


環境:OSX EI 10.11.1

昨天切換gem源后,招待pod安裝沒有任何問題,也可以正常用
$ gem sources --add https://ruby.taobao.org/ --remove https://rubygems.org/
$ sudo gem install cocoapods

今天再使用的時候,在一個項目下執行pod install時半天死活沒反應,無奈就ctrl+c了強制退出了。然后再執行的時候就出現錯誤:

Library/Ruby/Site/2.0.0/rubygems/dependency.rb:318:in `to_specs': Could not find 'cocoapods' (>= 0) among 33 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/Users/xianlong/.gem/ruby/2.0.0:/Library/Ruby/Gems/2.0.0:/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0', execute `gem env` for more information
from /Library/Ruby/Site/2.0.0/rubygems/dependency.rb:327:in `to_spec'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_gem.rb:64:in `gem'
from /usr/local/bin/pod:22:in `<main>'

 

分析可能是因為強制退出程序導致的配置被損壞。於是把pod卸載,重新安裝后就ok了。

卸載Pod:

step1:

which pod: 查看pod命令所在路徑,比如為/usr/local/bin/pod,然后執行 rm -rf /usr/local/bin/pod 將pod命令移除

 

step2:

執行gem list | grep cocoapods  查看所有與cocoapods相關的已安裝的組件,然后挨個卸載

我這里的執行結果是:

cocoapods-core (0.39.0)

cocoapods-downloader (0.9.3)

cocoapods-plugins (0.4.2)

cocoapods-search (0.1.0)

cocoapods-stats (0.6.2)

cocoapods-trunk (0.6.4)

cocoapods-try (0.5.1)

 

然后我就挨個執行:

gem uninstall cocoapods-core

gem uninstall cocoapods-downloader

gem uninstall cocoapods-plugins

gem uninstall cocoapods-search

gem uninstall cocoapods-stats

gem uninstall cocoapods-trunk

gem uninstall cocoapods-try

 

step3: 重新安裝pod

執行sudo gem install cocoapods, 提示出錯:While executing gem ... (Errno::EPERM)     Operation not permitted - /usr/bin/pod

在命令中指定安裝到/usr/bin/pods下即可正常安裝成功:

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

安裝成功,

 

step4: 查看新安裝的pod版本:

pod --version

0.39.0

 

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM