Jump to content

PEAR on Win32 - go-pear.bat:okay - pear.bat Error


fedoracore
 Share

Recommended Posts

first attempt at PEAR installation:PHP 5.2.4 - WinXP Sp2 - Apache 2.2the Initial instruction, post-installation [local, vs system-wide] tells me (not verbatim) "...old version found... remember to use ./php/pear.bat instead...."hence, the following command. note the feedback.

C:\PHP>pear.batNotice: unserialize(): Error at offset 375 of 566 bytes in Config.php on line 1007Notice: unserialize(): Error at offset 375 of 566 bytes in C:\PHP\PEAR\PEAR\Config.php on line 1007Call Stack:	0.0052	 259416   1. {main}() C:\PHP\PEAR\pearcmd.php:0	0.4794	2981008   2. PEAR_Config::singleton(string(0), string(0), ???) C:\PHP\PEAR\pearcmd.php:120	0.4795	2981520   3. PEAR_Config->PEAR_Config(string(0), string(0), bool,bool) C:\PHP\PEAR\PEAR\Config.php:645	0.5444	2986824   4. PEAR_Config->readConfigFile(string(19), string(4), bool) C:\PHP\PEAR\PEAR\Config.php:588	0.5444	2987984   5. PEAR_Config->_readConfigDataFrom(string(19)) C:\PHP\PEAR\PEAR\Config.php:693	0.5455	2990184   6. unserialize(string(566)) C:\PHP\PEAR\PEAR\Config.php:1007ERROR: The default config file is not a valid config file or is corrupted.

previous to this failure, i had tried a pear installation [same system, opting for "syste-wide" install however] on PHP 5.2.3 which claimed pear is "at my command". c:> pear but attempting to use it resulted in "no command by that name", (this of course after verifying PATH Env Vars were "correct" per instruction, restarting the sys, etc.) so i tried starting over w/ the newer PHP version. what do you suggest as a next step in trying to get PEAR Installer to function properly (so i might install, HTTP_Request, and other PEAR extensions via CLI commands)BTW-- the http://go-pear.org is apparently offline, though whether that update applies to my situation, i do not know.

Link to comment
Share on other sites

It sounds like something went wrong during installation, or it might be finding an older config file that it's trying to use with the newer version. What does the serialized string in the config.php file look like? It should be 566 characters long. There might also be help on pear's website somewhere for that error message.

Link to comment
Share on other sites

the only thing that looks odd to me is that i have 4 Config.php files, in the following locations:

C:\PHP\PEAR\PEAR\Config.php - 67.5 KbC:\PHP\PEAR\PEAR\Command\Config.php - 15.0 KbC:\PHP\tmp\PEAR-1.6.1\PEAR\Config.php - 67.5 KbC:\PHP\tmp\PEAR-1.6.1\PEAR\Command\Config.php - 15.0 Kb

Recall that this is a fresh install of PHP 5.2.4. I haven't altered any of the Dirs or Files manually, so after the go-pear.bat run, this is the result, unaltered.The smaller file is only 420 lines long, and the other, 2108 lines. Using jEdit's "JDiff" plugin, the files are quite obviously different.I've included the beginning few lines of both files for comparison.(sorry for all the copy / pasted code! but here's a look at the top of pearcmd.php as well... Lines 50 - 147.)I've marked Line 120 of pearcmd.php [the only alteration i've made to the original code below]. Line 120 references part two of the stack trace above.

// remove this next part when we stop supporting that crap-###### PHP 4.2if (!isset($_SERVER['argv']) && !isset($argv) && !isset($HTTP_SERVER_VARS['argv'])) {	echo 'ERROR: either use the CLI php executable, or set register_argc_argv=On in php.ini';	exit(1);}$argv = Console_Getopt::readPHPArgv();// fix CGI sapi oddity - the -- in pear.bat/pear is not removedif (php_sapi_name() != 'cli' && isset($argv[1]) && $argv[1] == '--') {	unset($argv[1]);	$argv = array_values($argv);}$progname = PEAR_RUNTYPE;if (in_array('getopt2', get_class_methods('Console_Getopt'))) {	array_shift($argv);	$options = Console_Getopt::getopt2($argv, "c:C:d:D:Gh?sSqu:vV");} else {	$options = Console_Getopt::getopt($argv, "c:C:d:D:Gh?sSqu:vV");}if (PEAR::isError($options)) {	usage($options);}$opts = $options[0];$fetype = 'CLI';if ($progname == 'gpear' || $progname == 'pear-gtk') {	$fetype = 'Gtk';} else {	foreach ($opts as $opt) {		if ($opt[0] == 'G') {			$fetype = 'Gtk';		}	}}//Check if Gtk and PHP >= 5.1.0if ($fetype == 'Gtk' && version_compare(phpversion(), '5.1.0', '>=')) {	$fetype = 'Gtk2';}$pear_user_config = '';$pear_system_config = '';$store_user_config = false;$store_system_config = false;$verbose = 1;foreach ($opts as $opt) {	switch ($opt[0]) {		case 'c':			$pear_user_config = $opt[1];			break;		case 'C':			$pear_system_config = $opt[1];			break;	}}PEAR_Command::setFrontendType($fetype);$ui = &PEAR_Command::getFrontendObject();[line120] $config = &PEAR_Config::singleton($pear_user_config, $pear_system_config);if (PEAR::isError($config)) {	$_file = '';	if ($pear_user_config !== false) {	   $_file .= $pear_user_config;	}	if ($pear_system_config !== false) {	   $_file .= '/' . $pear_system_config;	}	if ($_file == '/') {		$_file = 'The default config file';	}	$config->getMessage();	$ui->outputData("ERROR: $_file is not a valid config file or is corrupted.");	// We stop, we have no idea where we are :)	exit(1);	}

Config.php - 15 Kb:/** * PEAR_Command_Config (config-show, config-get, config-set, config-help, config-create commands) * * PHP versions 4 and 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt.  If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category   pear * @package	PEAR * @author	 Stig Bakken <ssb@php.net> * @author	 Greg Beaver <cellog@php.net> * @copyright  1997-2006 The PHP Group * @license	http://www.php.net/license/3_0.txt  PHP License 3.0 * @version	CVS: $Id: Config.php,v 1.53 2007/06/11 05:11:53 cellog Exp $ * @link	   http://pear.php.net/package/PEAR * @since	  File available since Release 0.1 *//** * base class */require_once 'PEAR/Command/Common.php';/** * PEAR commands for managing configuration data. * * @category   pear * @package	PEAR * @author	 Stig Bakken <ssb@php.net> * @author	 Greg Beaver <cellog@php.net> * @copyright  1997-2006 The PHP Group * @license	http://www.php.net/license/3_0.txt  PHP License 3.0 * @version	Release: 1.6.1 * @link	   http://pear.php.net/package/PEAR * @since	  Class available since Release 0.1 */class PEAR_Command_Config extends PEAR_Command_Common{...

Config.php - 67.5 Kb:/** * PEAR_Config, customized configuration handling for the PEAR Installer * * PHP versions 4 and 5 * * LICENSE: This source file is subject to version 3.0 of the PHP license * that is available through the world-wide-web at the following URI: * http://www.php.net/license/3_0.txt.  If you did not receive a copy of * the PHP License and are unable to obtain it through the web, please * send a note to license@php.net so we can mail you a copy immediately. * * @category   pear * @package	PEAR * @author	 Stig Bakken <ssb@php.net> * @author	 Greg Beaver <cellog@php.net> * @copyright  1997-2006 The PHP Group * @license	http://www.php.net/license/3_0.txt  PHP License 3.0 * @version	CVS: $Id: Config.php,v 1.137 2006/11/19 21:33:00 cellog Exp $ * @link	   http://pear.php.net/package/PEAR * @since	  File available since Release 0.1 *//** * Required for error handling */require_once 'PEAR.php';require_once 'PEAR/Registry.php';require_once 'PEAR/Installer/Role.php';require_once 'System.php';require_once 'PEAR/Remote.php';/** * Last created PEAR_Config instance. * @var object */$GLOBALS['_PEAR_Config_instance'] = null;if (!defined('PEAR_INSTALL_DIR') || !PEAR_INSTALL_DIR) {	$PEAR_INSTALL_DIR = PHP_LIBDIR . DIRECTORY_SEPARATOR . 'pear';} else {	$PEAR_INSTALL_DIR = PEAR_INSTALL_DIR;}// Below we define constants with default values for all configuration// parameters except username/password.  All of them can have their// defaults set through environment variables.  The reason we use the// PHP_ prefix is for some security, PHP protects environment// variables starting with PHP_*.// default channel and preferred mirror is based on whether we are invoked through// the "pear" or the "pecl" command...

Config.php - [ (65 Kb)- to show line 1007]:		$version = false;		if (preg_match('/^#PEAR_Config\s+(\S+)\s+/si', $contents, $matches)) {			$version = $matches[1];			$contents = substr($contents, strlen($matches[0]));		} else {			// Museum config file			if (substr($contents,0,2) == 'a:') {				$version = '0.1';			}		}		if ($version && version_compare("$version", '1', '<')) {			// no '@', it is possible that unserialize			// raises a notice but it seems to block IO to			// STDOUT if a '@' is used and a notice is raise[line 1007]			$data = unserialize($contents);			if (!is_array($data) && !$data) {				if ($contents == serialize(false)) {					$data = array();				} else {					$err = $this->raiseError("PEAR_Config: bad data in $file");					return $err;				}			}

Link to comment
Share on other sites

Oh dear... try to just reinstall PHP and be over with it. And only then use the go-pear.bat file, installing the PEAR installer with the default settings, clicking "Enter" all the way (or not if you know what you're doing).

Link to comment
Share on other sites

...And only then use the go-pear.bat file
is this to suggest that the go-pear.bat is not the desired approach to installing "PEAR" on Windows XP, that is-- the Pear command line installer (ie. so i can ultimately just do like i would on Fedora, such as: > pear install Some_Package)?My confusion is in part due to my not understanding what's going on with PHP5 and PEAR as a default installation. I mean-- what is the difference between "what is now", and "what was"? My understanding, from these trials and many errors, is that-- even though PEAR comes down w/ PHP5, the Windows user must still perform some action to in fact integrate it into the system (i.e. go-pear.bat).My current PHP5 installation is just from the binaries. I don't see any benefit from the recommended MSI-- in fact, it seems to muck things up! So i took the PHP5 MSI bit off (add / remove - uninstall), and am currently using the binaries installation. Everything recorded here is from a binaries install-- however, when i previously tried to install PEAR installer, it was on the PHP5 MSI install, and this seemed to be more successful-- to a point. I say that only because I did get my PEAR_ENV.reg (forgive any misnomer there), and it put C:\PHP\.\php.exe in the XP PATH. I thought the \.\ looked wrong, however-- and needless to say, after rebooting, i had no [ CLI> pear ] functionality, hence the re-try with the binaries.grrr....the pear.ini is in C:\PHP\ , for having chosen a "local" installation. It's my understanding, and from experience, the pear.ini goes under C:\Windows\ when the "system-wide" option is selected.CONTENTS OF PEAR.INI (current):
#PEAR_Config 0.9a:10:{s:15:"preferred_state";s:6:"stable";s:8:"temp_dir";s:10:"C:\PHP\tmp";s:12:"download_dir";s:10:"C:\PHP\tmp";s:7:"bin_dir";s:6:"C:\PHP";s:7:"php_dir";s:11:"C:\PHP\pear";s:7:"doc_dir";s:16:"C:\PHP\pear\docs";s:8:"data_dir";s:16:"C:\PHP\pear\data";s:8:"test_dir";s:17:"C:\PHP\pear\tests";s:7:"php_bin";s:16:"C:\PHP\.\php.exe";s:10:"__channels";a:2:{s:5:"__uri";a:0:{}s:12:"pecl.php.net";a:0:{}}}

CONTENTS OF PEAR.INI (previous, system-wide):#PEAR_Config 0.9

a:10:{s:15:"preferred_state";s:6:"stable";s:8:"temp_dir";s:16:"C:\PHP_5.2.3\tmp";s:12:"download_dir";s:16:"C:\PHP_5.2.3\tmp";s:7:"bin_dir";s:12:"C:\PHP_5.2.3";s:7:"php_dir";s:17:"C:\PHP_5.2.3\pear";s:7:"doc_dir";s:22:"C:\PHP_5.2.3\pear\docs";s:8:"data_dir";s:22:"C:\PHP_5.2.3\pear\data";s:8:"test_dir";s:23:"C:\PHP_5.2.3\pear\tests";s:7:"php_bin";s:22:"C:\PHP_5.2.3\.\php.exe";s:10:"__channels";a:2:{s:12:"pecl.php.net";a:0:{}s:5:"__uri";a:0:{}}}

note. i just realized this old pear.ini was still under C:\Windows\ . I've removed it. i'll let you know if it changes anything. i'm betting on "no". ;-)thanks for your help so far!EDIT: well, i'm eating my hat! removing the old pear.ini from the C:\Windows dir seems to have done the trick!all seems well in the world of fruitloops! i'm executing pear commands and installing stuff... woo hoothanks!

Link to comment
Share on other sites

Both of those serialized arrays look fine, but neither of them look like what is actually being used. From the stack trace:unserialize(string(566))It is trying to unserialize a string that is 566 bytes and running into a problem on byte 375. The array in the first file you posted is 398 bytes, and the second one is 447 bytes. Neither of them have a problem around 375. It doesn't look like it's using either of those. Do a search on your machine for files called "pear.ini" and see how many come up. Also, in config.php right before line 1007 you can also just print $content to see the string it's trying to unserialize. You wouldn't be able to fix the problem there though, you still need to know where it's getting that serialized data from.

Link to comment
Share on other sites

is this to suggest that the go-pear.bat is not the desired approach to installing "PEAR" on Windows XP, that is-- the Pear command line installer (ie. so i can ultimately just do like i would on Fedora, such as: > pear install Some_Package)?
No. It is the reccomended way. But you have to know what you're doing when you launch it. If you don't, just press "Enter" all the way to install it with the default configurations. Once you have installed it though, there's no way how it messed up the rest of the filesystem, so it's only logical to delete it, and PHP as a whole.
I mean-- what is the difference between "what is now", and "what was"?
Folders are created, php.ini values are edited, etc.
My understanding, from these trials and many errors, is that-- even though PEAR comes down w/ PHP5, the Windows user must still perform some action to in fact integrate it into the system (i.e. go-pear.bat).)
correct.
My current PHP5 installation is just from the binaries.
Point stands. Delete all PHP files and folders and reextract them to that place. This especially includes the php.ini file, so don't think of keeping it for ease of installation. With the new installation in place, launch go-pear.bat and don't change any of it's configuration options. Just press "Enter" all the way until the go-pear.bat file shuts down.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...