📱

cocoapods のアップデートに失敗する

2018/06/11に公開

TL;DR

cocoapod がインストールされている場所を調べて、 gem update をかけるときにその場所を指定してあげる。

アップデートと失敗の履歴

普通にコマンドを叩く

$ gem update cocoapods

Updating cocoapods
Fetching: cocoapods-core-1.5.2.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /Library/Ruby/Gems/2.3.0 directory.

sudo をつけてみる

$ sudo gem update cocoapods

Password:
Updating installed gems
Updating cocoapods
Fetching: cocoapods-core-1.5.2.gem (100%)
Successfully installed cocoapods-core-1.5.2
Fetching: cocoapods-1.5.2.gem (100%)
ERROR:  While executing gem ... (Gem::FilePermissionError)
    You don't have write permissions for the /usr/bin directory.

成功例

cocoapod のインストール場所を調べる

$ which pod

/usr/local/bin/pod

場所を指定してアップデートする

$sudo gem update cocoapods -n /usr/local/bin

Updating installed gems
Updating cocoapods
Successfully installed cocoapods-1.5.2
Parsing documentation for cocoapods-1.5.2
Installing ri documentation for cocoapods-1.5.2
Installing darkfish documentation for cocoapods-1.5.2
Done installing documentation for cocoapods after 10 seconds
Parsing documentation for cocoapods-1.5.2
Done installing documentation for cocoapods after 4 seconds
Gems updated: cocoapods

Discussion