Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

php

windows

pear

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!

like image 810
ARV Avatar asked May 01 '12 11:05

ARV


2 Answers

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.

like image 64
Tom Walker Avatar answered Nov 15 '22 16:11

Tom Walker


I was able to fix this by opening the command prompt as administrator. This is done by right-clicking on the command prompt icon and selecting 'Run as Administrator'. Once command prompt is open, navigate to your php directory and run: php go-pear.phar again. Should run without an issue.

The issue is, when you open your command prompt, your current account doesn't have the privilege to write to your windows directory. Running your command prompt as administrator, will allow for writing to c:\windows

Hope this helps.

like image 30
Timothy McCune Avatar answered Nov 15 '22 18:11

Timothy McCune