PHP: PEAR on windows tries to open c:\windows\pear.ini for writing even though the configuration file is c:\pear\pear.ini

ARV picture ARV · May 1, 2012 · Viewed 9.2k times · Source

On Windows, when I run

pear config-set auto_discover 1

I get the following error

PEAR_Config::writeConfigFile fopen('C:\Windows\pear.ini','w') failed (fopen(C:\Windows\pear.ini): failed to open stream: Permission denied)

even though I had mentioned during PEAR installation that my config file was c:\pear\pear.ini.

How to fix this, please (without running PEAR in admin mode or changing the permissions of c:\windows\pear.ini)? I guess my problem will be solved if I can figure out where PEAR is getting the directory for pear.ini from.

Thanks!

Answer

Tom Walker picture Tom Walker · Aug 4, 2012

In the PEAR installation, when I got to the step of modifying the paths I changed the path for pear.ini from C:\Windows\pear.ini to $prefix\pear.ini and I still ran into this same error. Apparently the installation script did not update everything that it needed to.

Based on a comment on a bug report for PEAR (http://pear.php.net/bugs/bug.php?id=16939), I added an environment variable PHP_PEAR_SYSCONF_DIR to point to my PEAR install folder (C:\php\PEAR).

I am now able to successfully run the same config-set command that you were initially attempting to run.

Note the follow-on comment on the bug report however. I only needed one PEAR installation on my machine whereas you may need multiple installations.