Workaround for PEAR/PECL Failure with Message “ERROR: `phpize’ failed”

Posted Monday, May 11th, 2009 at 10:24 am

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

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

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]


  1. silly hacker
    Posted Thursday, July 23rd, 2009 at 12:00 pm | Permalink

    Worked for me. Slackware 12.1.0

  2. Hamid
    Posted Saturday, July 25th, 2009 at 5:15 pm | Permalink

    Thanks, but your patch did not work for me though the symptom in my problem was failure in make, not phpize.

  3. Mikael
    Posted Thursday, August 13th, 2009 at 4:22 am | Permalink

    That worked well for me, Slackware 11.0 (maybe it’s time to upgrade…)

  4. Posted Wednesday, August 26th, 2009 at 10:54 am | Permalink

    @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.

  5. jebro
    Posted Tuesday, October 27th, 2009 at 1:10 pm | Permalink

    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

  6. Sean O'Brien
    Posted Monday, November 2nd, 2009 at 1:44 pm | Permalink

    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!

  7. NoXcuz
    Posted Saturday, November 14th, 2009 at 5:14 pm | Permalink

    Tried installing pdflib using pecl and recieved the error “phpize failed”. Found your patch and it worked like a charm on Slack 13.0!

  8. Cristian Navalici
    Posted Thursday, December 3rd, 2009 at 3:36 am | Permalink

    It worked for me also (when tried to install xdebug).
    Slackware 13.0

    Many thanks!

  9. b_o_y_a_n
    Posted Friday, February 12th, 2010 at 8:32 pm | Permalink

    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 🙂

  10. hoschi
    Posted Sunday, June 27th, 2010 at 8:48 am | Permalink

    The Patch didn’t work for me:
    PEAR 1.9.1 on Ubuntu Lucid Lynx (10.4)

  11. patryk
    Posted Monday, November 8th, 2010 at 2:39 pm | Permalink

    works fine and solves the problem for:

    slackware 13.1,
    PHP 5.2.13,
    PEAR Release: 1.9.1

  12. Posted Monday, November 15th, 2010 at 8:54 am | Permalink

    Worked for me

    Slackware 13.1
    PEAR Version: 1.9.1
    PHP Version: 5.3.3

  13. Ray
    Posted Thursday, November 18th, 2010 at 6:26 pm | Permalink

    Works for me. I’ve been looking for a fix for this. thanks!

  14. Ian
    Posted Thursday, April 7th, 2011 at 2:12 pm | Permalink

    Here’s the error I get when I run this:

    (Stripping trailing CRs from patch.)
    patching file Builder.php
    Hunk #1 FAILED at 457.
    Hunk #2 FAILED at 480.
    2 out of 2 hunks FAILED — saving rejects to file Builder.php.rej

    PHP version: 5.1.2

  15. wuqinghui
    Posted Monday, April 18th, 2011 at 6:28 pm | Permalink

    [Kai says: I’m approving this comment, even though I’m not sure what it says, on the hope that it might prove useful to any other Chinese-speakers who arrive here looking for help on this issue.]

    我的英语不好(my english is badly.)
    软件包(soft pkg):pear包已全部安装 (all pkg install)
    问题(question):pear不能帮定到php,在php中调用pear的DB、mail时,没有响应。(pear can’t use php,php use pear’s DB and mail,no responded.)
    include_path = “/usr/local/lib/php”
    结果(a result):no problem

  16. alkos333
    Posted Sunday, May 15th, 2011 at 8:58 am | Permalink

    Very neat workaround. I like how you parsed the configure command and then used that in the conditional for the pclose() exit code.

    Nice work!

  17. Posted Thursday, June 2nd, 2011 at 1:46 am | Permalink

    Fixed the patch for slackware 13.37/PHP 5.3.6:


  18. madods
    Posted Thursday, July 14th, 2011 at 4:21 pm | Permalink

    Thanks for the patch. It got me out of a hole trying to install PDFLib on Slackware 12.2. Great work!

  19. Alessandro
    Posted Wednesday, August 31st, 2011 at 5:58 am | Permalink

    It worked, thank you very much!! (Slackware 12.0)

  20. Joop Siroop
    Posted Sunday, September 4th, 2011 at 1:10 pm | Permalink

    Works great on my 64 bit Slackware 13.37!

    I compiled php 5.3.8 without the –enable-sigchild flag.
    I guess it’s default then and a –disable-sigchild is needed.

    However, youre patchfile did the trick.

  21. Posted Friday, January 6th, 2012 at 4:12 am | Permalink

    It didn’t work for me:

    root@dragon:patch -p0 < patch

    patching file Builder.php
    Hunk #1 succeeded at 472 (offset 8 lines).
    patch: **** malformed patch at line 47: 2))));

    I tried also the foxed path that Dave give and it didn't work also.

  22. Mike
    Posted Saturday, February 18th, 2012 at 11:16 am | Permalink

    Worked a treat:

    PEAR 1.9.4
    PHP 5.3.10
    Fedora 16

  23. Posted Tuesday, February 28th, 2012 at 1:52 am | Permalink

    If you don’t have patch command installed like I did on pure linux, try
    rpm -ivh

  24. Roger256
    Posted Saturday, February 9th, 2013 at 3:31 pm | Permalink

    Works on Slackware 13.37 with PHP 5.3.17, thanks a lot !

  25. e lizzle
    Posted Friday, January 3rd, 2014 at 1:45 pm | Permalink

    Thanks for this post! We had sigchild enabled for years, since we’re running PHP against Oracle. I was completely stuck trying to use PECL to install a module, was going to have to tarball it. Found your article, recompiled php without sigchild, and now I can use pecl!

3 Trackbacks

  1. By Kagan MacTane on Monday, May 11th, 2009 at 10:24 am

    On Twitter, Kagan MacTane said: New blog post: Workaround for PEAR/PECL Failure with Message “ERROR: `phpize’ failed”
    Trackback powered by Topsy

  2. By Bojan Ristic on Friday, February 12th, 2010 at 7:23 pm

    RT @kmactane: New blog post: Workaround for PEAR/PECL Failure with Message "ERROR: `phpize' failed"

  3. By ERROR: `phpize' failed on Friday, January 6th, 2012 at 1:01 am

    […] php with some option for phpize? kode No, You can try the patch in my previous post. See here what you need to do. Just don't forget to backup Builder.php […]

Post a Comment

Your email is never shared. Required fields are marked *