search
LoginSignup
30
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

posted at

macOS High Sierra で Ansible 入れようとしたら失敗した。

Homebrew で Ansible 入れようとしたら失敗しました。
環境:macOS High Sierra 10.13

$ brew install ansible
==> Installing ansible dependency: gdbm
==> Downloading https://homebrew.bintray.com/bottles/gdbm-1.13.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring gdbm-1.13.high_sierra.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink include/gdbm.h
/usr/local/include is not writable.
==> Installing ansible dependency: libyaml
==> Downloading https://homebrew.bintray.com/bottles/libyaml-0.1.7.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libyaml-0.1.7.high_sierra.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink include/yaml.h
/usr/local/include is not writable.
==> Installing ansible dependency: python
Warning: Building python from source:
  The bottle needs the Apple Command Line Tools to be installed.
  You can install them, if desired, with:
    xcode-select --install

==> Downloading https://www.python.org/ftp/python/2.7.14/Python-2.7.14.tar.xz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/python/2.7.14 --enable-ipv6 --datarootdir=/usr/local/Cellar/python/2.7.14/share --datadir=/usr/local/Cellar/p
==> make
==> make install PYTHONAPPSDIR=/usr/local/Cellar/python/2.7.14
==> make frameworkinstallextras PYTHONAPPSDIR=/usr/local/Cellar/python/2.7.14/share/python
==> Downloading https://files.pythonhosted.org/packages/a4/c8/9a7a47f683d54d83f648d37c3e180317f80dc126a304c45dc6663246233a/setuptools-36.5.0.zip
######################################################################## 100.0%
==> Downloading https://files.pythonhosted.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz
######################################################################## 100.0%
==> Downloading https://files.pythonhosted.org/packages/fa/b4/f9886517624a4dcb81a1d766f68034344b7565db69f13d52697222daeb72/wheel-0.30.0.tar.gz
######################################################################## 100.0%
Error: An unexpected error occurred during the `brew link` step
The formula built, but is not symlinked into /usr/local
Permission denied @ dir_s_mkdir - /usr/local/lib
Error: Permission denied @ dir_s_mkdir - /usr/local/lib

/usr/local/lib とか /usr/local/include に書き込み権限がないみたいです。
解決策調べてたら、単純に sudo chown -R $(whoami) $(brew --prefix) で権限変更しろというのがあったのでやってみましたが失敗。

$ sudo chown -R $(whoami) $(brew --prefix)
chown: /usr/local: Operation not permitted

どうも High Sierra からは上記の操作ができなくなったようです。
https://github.com/Homebrew/brew/issues/3228

結論は上記リンクに書いてありますが、/usr/local/以下のディレクトリを個別に chown で対処できました。必要なディレクトリは先に mkdir しておく必要があります。

$ sudo mkdir /usr/local/lib
$ sudo mkdir /usr/local/include
$ sudo mkdir /usr/local/Frameworks
$ sudo mkdir /usr/local/Frameworks/Python.framework
$ sudo chown -R $(whoami) $(brew --prefix)/*

上記を実行後、Ansible インストールで失敗したところをやりなおして終了。

$ brew link gdbm
Linking /usr/local/Cellar/gdbm/1.13... 12 symlinks created
$ brew link libyaml
Linking /usr/local/Cellar/libyaml/0.1.7... 5 symlinks created
$ brew link python
Linking /usr/local/Cellar/python/2.7.14... 26 symlinks created

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
What you can do with signing up
30
Help us understand the problem. What are the problem?