LoginSignup
6
1

More than 5 years have passed since last update.

macOS SierraにCarthageを無理やりインストールする

Last updated at Posted at 2017-01-23

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)
$ brew -v
Homebrew 1.1.7-88-g3be56aep
Homebrew/homebrew-core (git revision 35975; last commit 2017-01-23)

普通にbrew installするとPermission denined

まずは普通に brew install してみます。

PermissionDenied
$ 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がそれはやってはいけないと諭してくれます。

homebrewはsudoで実行してはいけない
$ sudo brew install Carthage
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. と言われるが使える状態にはなっていない。

インストールできた?と思うけど出来てません
$ brew install Carthage -f
Updating Homebrew...
Warning: carthage-0.18.1 already installed, it's just not linked.

再度、綺麗な状態に戻す

シンボリックリンクやソースを削除して、綺麗な(と思われる)状態に戻します。

シンボリックリンクを削除
$ brew unlink carthage
Unlinking /usr/local/Cellar/carthage/0.18.1... 0 symlinks removed
ソースを削除
$ brew uninstall carthage
Uninstalling /usr/local/Cellar/carthage/0.18.1... (49 files, 12.4M)

手動でディレクトリを作ってPermissionを設定する

最初のエラーは Error: Permission denied - /usr/local/Frameworks でした。/usr/local/Frameworks を使おうとして権限がないのでダメだったようです。そもそもディレクトリはあるのでしょうか?

/usr/local/Frameworksを確認
$ ls -ltr /usr/local/Frameworks
ls: /usr/local/Frameworks: No such file or directory

/usr/local/Frameworksは存在しないようです。どうやら/usr/local配下にFrameworksを作成しようとしてPermission deniedになったようです。/usr/local はroot権限が必要なのでそれはそうです。

/usr/localはroot権限が必要
drwxr-xr-x    15 root  wheel   510B  1 23 22:15 local

涙を拭いてディレクトリを作成します。

sudoで/usr/local/Frameworksを作成
$ sudo mkdir /usr/local/Frameworks

続いて所有者を自分に変更します。

所有者を自分に変更
$ sudo chown -R  myuser:staff /usr/local/Frameworks

homebrewで再度インストールします。

もう一度インストール
$ brew install carthage
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
$

インストールできました。本当はどうインストールするのが正しいのか....

6
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
1