LoginSignup
12
12

More than 5 years have passed since last update.

Laravelの環境構築で、phpbrew,phpコマンドが動かなくなってしまった話

Last updated at Posted at 2016-10-17
ターミナル
brew install homebrew/php/composer
php -v

composerインストール後にphpコマンドが動作しなくなった。

エラー文
dyld: Library not loaded: /usr/local/opt/readline/lib/libreadline.6.dylib
  Referenced from: /Users/(ユーザー名)/.phpbrew/php/php-5.6.23/bin/php
  Reason: image not found

原因

libreadline.6.dylibが存在していないことが発覚。パスを確認すると、Homebrewのパッケージであるreadlineに問題があるらしい。

ただ、いきなりディレクトリを直接弄るのは怖いので、まずはReadlineのサマリーを出力(Homebrew便利)

ターミナル
brew info readline

readline: stable 7.0 (bottled) [keg-only]
/usr/local/Cellar/readline/7.0 (45 files, 2.1M)
  Poured from bottle on 2016-10-16 at 17:58:37
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/readline.rb

==> Caveats

readlineのバージョン(7.0)と、phpbrewが求めているreadlineのバージョン(6.x)がマッチしていないため動作しないことが判明

解決策

phpbrew側がreadline7を要求するようにしてくれれば万事解決できたのだが、そのような手段が見つからず断念。(Teratailで質問しても回答者様現れず………)

そこで、readline6を本家リファレンスからダウンロード&インストールすることに決めた。

ちなみにhomebrewで別バージョンをインストールしようと試みたが、最近のhomebrewでは、versionsコマンドが廃止された為出来なくなってしまった。

手順

1.こちらにアクセスし、リストにあるreadline-6.3.tar.gzをダウンロード&ファイルを解凍する。

2.展開されたファイルを/usr/local/Cellarディレクトリに配置する
※ Cellarの場所が分からなかった場合、open /usr/local/Cellar/を実行するとFinderが表示してくれる

3.ターミナルで以下のコマンドを実行

ターミナル
cd /usr/local/Cellar/readline-6.3

pwd 
#/usr/local/Cellar/readline-6.3にいることを確認
./configure --prefix=/usr/local/Cellar/readline/6.3 --mandir=/usr/local/Cellar/readline/6.3/share/man --infodir=/usr/local/Cellar/readline/6.3/share/info --enable-multibyte

make

make install

これで、readlineに6.3のバージョンを導入完了。

4.バージョン6.3が入っているかどうか確認
brew info readlineを実行して、6.3が追加されていることを確かめる。

ターミナル
readline: stable 7.0 (bottled) [keg-only]
Library for command-line editing
https://tiswww.case.edu/php/chet/readline/rltop.html
/usr/local/Cellar/readline/6.3 (39 files, 1.9M)
  Built from source
/usr/local/Cellar/readline/7.0 (45 files, 2.1M)
  Poured from bottle on 2016-10-16 at 17:58:37
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/readline.rb
==> Caveats

5.readlineを7.0から6.3に切り替える

ターミナル
brew switch readline 6.3

最後にphp,phpbrewコマンドを実行して動作したら成功

ターミナル
> $ php -v

PHP 5.6.23 (cli) (built: Oct 16 2016 01:45:49)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

参考にしたサイト:
- 6.35. Readline-6.3
- psqlしたらreadlineのエラーが出るようになって
- Macにpython3開発環境を構築する (pyenv導入)

12
12
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
12
12