LoginSignup
0
0

M2 macでxdebugがインストールできなくて困った話

Last updated at Posted at 2023-09-11

結論

sudo 付けたら行けた。

> sudo pecl install xdebug

経緯

pecl install xdebugすると、エラーが出るし、手動でビルドするかー。

環境情報

> sw_vers
ProductName:		macOS
ProductVersion:		13.5.2
BuildVersion:		22G91

> php -v
PHP 8.1.23 (cli) (built: Aug 31 2023 18:43:16) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.23, Copyright (c) Zend Technologies
    with Xdebug v3.2.2, Copyright (c) 2002-2023, by Derick Rethans
    with Zend OPcache v8.1.23, Copyright (c), by Zend Technologies

手動でビルドするも

手動でビルドしようと思い実行

> git clone https://github.com/xdebug/xdebug.git
> cd xdebug
> phpize
> ./configure
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for pkg-config... /opt/homebrew/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking whether the C compiler works... no
configure: error: in `/path_to_dir/xdebug':
configure: error: C compiler cannot create executables
See `config.log' for more details

C compiler cannot create executablesか、config.logを見るか...

...
configure:3263: /usr/bin/gcc -V >&5
clang: error: argument to '-V' is missing (expected 1 value)
clang: error: no input files
configure:3274: $? = 1
configure:3263: /usr/bin/gcc -qversion >&5
clang: error: unknown argument '-qversion'; did you mean '--version'?
clang: error: no input files
configure:3274: $? = 1
configure:3263: /usr/bin/gcc -version >&5
clang: error: unknown argument '-version'; did you mean '--version'?
clang: error: no input files

これかな?と思いつつ、ググると「'-V'や'-qversion'は昔のコマンドです」という情報がたくさん出てくる。
2日間に色々解決策を試すも、エラーの解消が出来ず。

解決編

寝て起きた時、なんとなくsudoしてみた。(本当はよくない)

> sudo ./configure
Password:
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for a sed that does not truncate output... /usr/bin/sed
checking for pkg-config... /opt/homebrew/bin/pkg-config
checking pkg-config is at least version 0.9.0... yes
checking for cc... cc
checking whether the C compiler works... yes

行けた!
あとは、makeだけ。

> make 
...
(cd .libs && rm -f xdebug.la && ln -s ../xdebug.la xdebug.la)
/bin/sh /Users/path/dev/xdebug/libtool --mode=install cp ./xdebug.la /Users/path/dev/xdebug/modules
cp ./.libs/xdebug.so /Users/path/dev/xdebug/modules/xdebug.so
cp: /Users/path/dev/xdebug/modules/xdebug.so: Permission denied
make: *** [/Users/path/dev/xdebug/modules/xdebug.la] Error 1

む、結構行けてるということは、peclにsudoつければいけるかも。

> sudo pecl install xdebug
...
Build process completed successfully
Installing '/opt/homebrew/Cellar/php@8.1/8.1.23/pecl/20210902/xdebug.so'
install ok: channel://pecl.php.net/xdebug-3.2.2
Extension xdebug enabled in php.ini

感想

sudo付けたら解決する問題は稀によくある。

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