事象
CocoaPodsのバージョンが古くインストールできないPodがあったため、CocoaPodsをアップデートしようとしたら、エラー発生!!以下のエラーの解決法法を紹介します。
※今回のリサーチでわかった解決方法は以下の通りですが、なにか他に方法がありましたら教えてください。
You don't have write permissions for the /usr/bin directory
事象発生までの流れ
Cocoapodsのバージョンをアップデートしよう以下のコマンドを実行
$ sudo gem uninstall cocoapods
エラー発生
/usr/bin directory.に書き込む権限がないらしい。
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /usr/bin directory.
理由
Catalinaでは、Systemファイルにはライトプロテクトがかかっており、書き込みや削除ができない。
引用:
"Catalina has a new file system arrangement where most of the system files are write-protected. Apple uses two partitions, a read-only one for the main system files and a writeable one for other files, and melds them together and presents them as one to the user.
[For details see the WWDC video What's New in Apple Filesystems]"(https://developer.apple.com/videos/play/wwdc2019/710/#,"")
解決方法
$ sudo gem install cocoapods -n /usr/local/bin
"-n"は、既存のファイルを上書きしないという意味。これでライトプロテクトを回避できるのか!
出典:【 mv 】コマンド――ファイルやディレクトリを移動する/名前を変更する
pod setupはしなくてみいいみたいです。
$ pod setup
引用:
"Yes that is intended. The current 1.8.0 pod setup does not do anything and we have kept it if we need it in the future and to avoid breaking systems that depend on it.
I can keep this open with a tiny enhancement that prints out a message the "Setup completed successfully." or something."
Cocoapods GitHub: No output from pod setup #9184
参考文献
1.CocoaPodsのバージョンアップの方法
2.You don't have write permissions for the /usr/bin directory. while installing Cocoapods
3.SIP is disabled, but /usr/bin is write protected anyway (macOS Catalina beta 10.5)