CarthageはSwift製のパッケージ管理ツールです。macOS SierraにCarthageをインストールしようとしてエラーが発生したので備忘録としてW/Aと共に残しておきます。
環境は以下です。
- OS: macOS 0.12.1(16B2657)
- Homebrew: 1.1.7-88-g3be56ae
- Homebrew/homebrew-core: (git revision 35975; last commit 2017-01-23)
Homebrew 1.1.7-88-g3be56aep Homebrew/homebrew-core (git revision 35975; last commit 2017-01-23)
普通にbrew installするとPermission denined
まずは普通に brew install
してみます。
brew install Carthage
Updating Homebrew... ==> Auto-updated Homebrew! Updated Homebrew from 950e279 to 3be56ae. Updated 3 taps (homebrew/core, homebrew/python, homebrew/science). ~~~ 省略 ~~~~ ==> Downloading https://homebrew.bintray.com/bottles/carthage-0.18.1.sierra.bottle.tar.gz Already downloaded: /Users/myuser/Library/Caches/Homebrew/carthage-0.18.1.sierra.bottle.tar.gz ==> Pouring carthage-0.18.1.sierra.bottle.tar.gz Error: An unexpected error occurred during the `brew link` step The formula built, but is not symlinked into /usr/local Permission denied - /usr/local/Frameworks Error: Permission denied - /usr/local/Frameworks
Permission denied - /usr/local/Frameworks
とエラーメッセージが表示され、インストールできません。
sudoでのインストールはhomebrewが受け付けない
sudoでhomebrewを実行しようとするとhomebrewがそれはやってはいけないと諭してくれます。
Error: Running Homebrew as root is extremely dangerous and no longer supported. As Homebrew does not drop privileges on installation you would be giving all build scripts full access to your system.
この後で再度、インストールを実行すると already installed, it's just not linked.
と言われるが使える状態にはなっていない。
Updating Homebrew... Warning: carthage-0.18.1 already installed, it's just not linked.
再度、綺麗な状態に戻す
シンボリックリンクやソースを削除して、綺麗な(と思われる)状態に戻します。
Unlinking /usr/local/Cellar/carthage/0.18.1... 0 symlinks removed
Uninstalling /usr/local/Cellar/carthage/0.18.1... (49 files, 12.4M)
手動でディレクトリを作ってPermissionを設定する
最初のエラーは Error: Permission denied - /usr/local/Frameworks
でした。
/usr/local/Frameworks
を使おうとして権限がないのでダメだったようです。そもそもディレクトリはあるのでしょうか?
Uninstalling /usr/local/Cellar/carthage/0.18.1... (49 files, 12.4M)
ls: /usr/local/Frameworks: No such file or directory
/usr/local/Frameworksは存在しないようです。 どうやら/usr/local配下にFrameworksを作成しようとしてPermission deniedになったようです。 /usr/local はroot権限が必要なのでそれはそうです。
drwxr-xr-x 15 root wheel 510B 1 23 22:15 local
涙を拭いてディレクトリを作成します。
続いて所有者を自分に変更します。
homebrewで再度インストールします。
Updating Homebrew... ==> Auto-updated Homebrew! Updated 1 tap (homebrew/core). No changes to formulae. ==> Downloading https://homebrew.bintray.com/bottles/carthage-0.18.1.sierra.bottle.tar.gz Already downloaded: /Users/myuser/Library/Caches/Homebrew/carthage-0.18.1.sierra.bottle.tar.gz ==> Pouring carthage-0.18.1.sierra.bottle.tar.gz ==> Caveats Bash completion has been installed to: /usr/local/etc/bash_completion.d zsh completion has been installed to: /usr/local/share/zsh/site-functions ==> Summary 🍺 /usr/local/Cellar/carthage/0.18.1: 49 files, 12.4M
インストールできました。本当はどうインストールするのが正しいのか….