When you try to upgrade or install various PEAR (or PECL) packages, you may get the rather unhelpful error message “ERROR: `phpize’ failed”. For example, here’s the result I get when I try to install the pecl_http package:
root@finrod:~# pecl install pecl_http
pecl/pecl_http can optionally use PHP extension "iconv"
downloading pecl_http-1.6.3.tar ...
Starting to download pecl_http-1.6.3.tar (Unknown size)
................................................................................
................................................................................
.........................................done: 1,015,808 bytes
71 source files, building
running: phpize
Configuring for:
PHP Api Version: 20041225
Zend Module Api No: 20060613
Zend Extension Api No: 220060519
ERROR: `phpize' failed
root@finrod:~#
The error is actually caused by a bug in PHP itself (filed in PHP’s bug database as of 2004, and currently marked “Won’t fix”): If your installation of PHP was compiled with the --enable-sigchild flag on, then the return value from a pclose() call can’t be trusted. One of PEAR’s components, called PEAR::Builder, uses pclose() as part of the package installation process, to try to determine whether a given operation succeeded or not.
Even though the operation succeeds, pclose() returns -1, signaling a failure, and the rest of PEAR then takes pclose() at its word.
Is This Affecting Your Installation of PHP and PEAR?
If you’ve gotten an “ERROR: `phpize’ failed” message when trying to run a “pecl install” or “pear install” command, try running phpinfo() — if you see --enable-sigchild in the “Configure Command” section near the very top, then you’re most likely being bitten by this bug.
Potential Fixes and Workarounds
The PHP dev team recommends recompiling without the offending flag.
However, you may not be able to do that, for any of various reasons. (You may have installed from a binary package, for instance — like most people these days.) Or it may simply seem like an excessive hassle. I offer the following patch as-is, without any guarantee or support.
First, ensure that you have the latest version of PEAR::Builder. Look in your PEAR/Builder.php file — On most Linux and Unix installations, this is likely to be in /usr/lib/php/PEAR/Builder.php, or possibly /usr/local/lib/php/PEAR/Builder.php.
On Windows systems, PHP might be installed nearly anywhere, but supposing it’s in c:\php, then the file you’re looking for will be in c:\php\PEAR\PEAR\Builder.php (yes, that’s two PEARs in a row).
Check the “@version” line in the big comment block at the beginning of the file; the line you want should be around line 19 or so. If says it’s less than version 1.38 (the latest one, at the time I’m writing this post), then try upgrading. Running “pear upgrade pear” should work. Then you can install this patch file:
Download the patch file and place it somewhere on your machine. Log in and cd to the PEAR directory that contains the Builder.php file. Then run the patch command. In the following example, I’ve placed the patch file in root’s home directory:
root@finrod:~# ls
loadlin16c.txt loadlin16c.zip patch-pear-builder-1.38.txt
root@finrod:~# cd /usr/lib/php/PEAR
root@finrod:/usr/lib/php/PEAR# cp Builder.php Builder.bak.php
root@finrod:/usr/lib/php/PEAR# patch -p0 < /root/patch-pear-builder-1.38.txt
patching file Builder.php
root@finrod:/usr/lib/php/PEAR#
Naturally, if the patch file doesn’t work for some reason, or it breaks things, you can just cp the backup file back into place.
Please let me know if this patch works for you — or if it fails horribly, for that matter.
[Updated 2009-06-03: Minor edits for clarity]
10 Comments
Worked for me. Slackware 12.1.0
Thanks, but your patch did not work for me though the symptom in my problem was failure in make, not phpize.
That worked well for me, Slackware 11.0 (maybe it’s time to upgrade…)
@Mikael #3: Hey, one of the things I like about the open-source world is that we’re not nearly as stuck on the “forced-upgrade treadmill”. If the machine’s still working, no need to upgrade unless *you* feel like it.
Glad to hear the patch was useful.
Hmm, it didn’t work for me, it just added a notice and two warnings:
running: phpize
sh: phpize: not found
Notice: Undefined variable: config in PEAR/Builder.php on line 507
Warning: Invalid argument supplied for foreach() in PEAR/Builder.php on line 507
Warning: Invalid argument supplied for foreach() in /usr/share/php/PEAR/Builder.php on line 507
ERROR: `phpize’ failed
Ubuntu 8.04.1, Builder version 1.9.0
Worked on this problem for about a week, about to give up, but I tried this.
Works beautifully.
Slackware 13.0.
Thank you very much, coyote!
Beautiful!
Tried installing pdflib using pecl and recieved the error “phpize failed”. Found your patch and it worked like a charm on Slack 13.0!
Thanks!
It worked for me also (when tried to install xdebug).
Slackware 13.0
Many thanks!
Works for me as well.
I have PHP 5.2.10 custom configured on Slackware 13.
Patch saved me a great deal of time.
thanks for this post
The Patch didn’t work for me:
PEAR 1.9.1 on Ubuntu Lucid Lynx (10.4)
2 Trackbacks
On Twitter, Kagan MacTane said: New blog post: Workaround for PEAR/PECL Failure with Message “ERROR: `phpize’ failed” http://bit.ly/t8ceg
Trackback powered by Topsy
RT @kmactane: New blog post: Workaround for PEAR/PECL Failure with Message "ERROR: `phpize' failed" http://bit.ly/t8ceg