PEAR Install Hang Fix

This is actually reprinted from the old blog, but it seemed potentially useful still.  At least, the search engines think so.

Do you have this problem? And you just can’t seem to fix it?

FIRST THING TO DO: try ‘pear install -Z xxx’ to download only the tar, not the tgz, and see if that works. It probably will, but if you don’t like having to use -Z then continue below.

SECOND THING TO DO: Try the go-pear.phar solution. If you can’t use it, prefer not to use it, or it doesn’t work, then try my solution.

NOTE: This is not a ZendStudioPlatform only solution, this should work for everyone, I simply reference ZendStudio/Platform because that’s what I use.

NOTE: This may not even be an OS X specific solution, it might work for you on other unix based platforms as well.

WARNING: If your PHP binary is susceptible to this bug then this solution probably still won’t work for you. Unfortunately I don’t hold the key to the solution to this bug, but if someone informs me of it, I’ll post it here.

You have a PHP4/5 installation on your OS X machine, say ZendStudio/Platform’s binaries (located in /Applications/ZendStudio/bin/php4/php or /Applications/ZendStudio/bin/php5/php), and you want to install PEAR using go-pear.php (pretty much the only way pear.php.net seems to give you to install the manager). Even though ZendStudio/Platform may list in the include path /usr/local/Zend/share/pear/, it wasn’t there, at least on my installation.

So you use go-pear.php, attempting the web-interface, and you probably get a ‘fatal ran out of memory’ error on installation (you might not, if you look below for a solution). I’m sure it gets to ‘installation ok’ and then kind of sits there. If you are using the command-line interface (CLI) you may encounter fatal memory errors, or an ‘installation ok’ and a hang.

If you ARE getting memory problems, find your ACTIVE php.ini file (it can be elusive, as other php.ini files may be hanging around. For Os X ZendStudio/Platform distributions, it is most likely in /Applications/ZendStudio/bin/php[45]/php.ini) Edit this php.ini file and place or replace the option: memory_limit = -1. This will cause your PHP distribution to disregard memory limitations. Make sure you are editing your active php.ini file. If you still receive memory problems, then your computer needs more memory.

And yes… as far as I could ascertain if you have this problem, the go-pear.php CLI (possibly web) installation will also hang after ‘installation ok: PEAR-1.6.0′ etc. Control-C the process after a few minutes.

Attempting to use your PEAR installation may also prove frustrating, as some elements may wor such as ‘pear list’, but others probably won’t, such as ‘pear install xxxx’. Instead it will most likely hang, which is what I’m here to solve, so that you may go on your merry PEAR way once and for all.

  1. Find your PEAR installation directory (likely: /usr/local/share/pear) and check to see if /PEAR/Archive/Tar.php exists. If it doesn’t go to step 2, if not, go to step 3.
  2. Download the Archive_Tar (1.3.2 stable) package directly from pear.php.net (link). Unpackage it, and copy the contents so that you have PEAR/Archive/Tar.php in your PEAR installation.
  3. Check to see if your share/pear directory has a Console directory in it, if it doesn’t go to step 4, otherwise go to step 5.
  4. Download the Console_Getopt package directly from pear.php.net (link). Unpackage it, and copy the contents (Console directory) so that you have share/pear/Console/Getopt.php in your installation.
  5. If you have Archive_Tar v1.3.2-stable (or higher) then open it and go to line 801 (I recommend using vim, :set nu). Comment out line 801, it does nothing. It’s supposed to, but it doesn’t. This original source of the error and the hang. The file pointer isn’t moved, although it should be, and the while loop is never broken out of. (If you re-install Archive_Tar as a normal PEAR package, you may have to make this fix again in /usr/local/share/pear/Archive/Tar.php )
  6. Under line 801, insert: _readBlock();
  7. This apparently advances the file pointer, like bz2. Before you try to run PEAR there are a few more things to check.
  8. If you do not have PEAR/Structures than you will need to download the Structures_Graph module by hand. Do so, and then move the Structures directory into your PEAR directory. Now proceed to step 6. If you DID have PEAR/Structures already skip to step 12.
  9. Now, open PEAR/Structures/Graph.php and change require_once( ‘Structures/Graph/Node.php’ ); to require_once( ‘PEAR/Structures/Graph/Node.php’ );
  10. Open PEAR/Structures/Graph/Node.php and change require_once( ‘Structures/Graph.php’ ); to require_once( ‘PEAR/Structures/Graph.php’ );
  11. Open PEAR/Structures/Graph/Manipulator/TopologicalSorter.php and replace require_once( ‘Structures/Graph.php’ ); with require_once( ‘PEAR/Structures/Graph.php’ );
    1. Replace require_once( ‘Structures/Graph/Node.php’ ); with require_once( ‘PEAR/Structures/Graph/Node.php’ );
    2. Replace require_once( ‘Structures/Graph/Manipulator/AcyclicTest.php’ ); with require_once( ‘PEAR/Structures/Graph/Manipulator/AcyclicTest.php’ );
  12. Open PEAR/Structures/Graph/Manipulator/AcyclicTest.php and replace require_once( ‘Structures/Graph.php’ ); with require_once( ‘PEAR/Structures/Graph.php’ );
    1. Replace require_once( ‘Structures/Graph/Node.php’ ); with require_once( ‘PEAR/Structures/Graph/Node.php’ );
  13. Voila, you are done. Now, try your ‘pear install xxxx’. It should work. 🙂

If you have any problems or questions, please give me a ring.

POSTFIX: If you have installed ZendStudio/Platform (ZDE) you can fix the pear path problem you might have by creating a symbolic/hard link (using ln) to /usr/local/share/pear inside /usr/local/Zend/share/ named pear.

photo credit: Pear Guy via photopin (license)

kadar

I'm just a wunk, trying to enjoy life. I am a cofounder of http//originalpursuitssoc.com/ and I like computers, code, creativity, and friends.

You may also like...

Leave a Reply

%d bloggers like this: