Skip to content

ERROR: failed to mkdir C:\php\pear\tests\PHP_CodeSniffer\CodeSniffer\Core\File [Solved]

If your PHP installation has been done somewhere else other than the C:\ drive, then “pear install” command may throw errors.

Example: Here in my case, the xampp has been installed into E:\ drive and the “pear install” throws error.

E:\xampp\php>pear install PHP_CodeSniffer
WARNING: channel "pear.php.net" has updated its protocols, use "pear channel-upd
ate pear.php.net" to update
downloading PHP_CodeSniffer-2.0.0.tgz ...
Starting to download PHP_CodeSniffer-2.0.0.tgz (448,559 bytes)
................................................................................
..........done: 448,559 bytes
ERROR: failed to mkdir C:\php\pear\tests\PHP_CodeSniffer\CodeSniffer\Core\File

Solution:
I get into the “pear” directory and checked config values set for different pear related directories. All were set to C:\ drive by default. So, we need to change those settings to correct path.

pear config-set doc_dir E:\xampp\php\pear
pear config-set cfg_dir E:\xampp\php\pear
pear config-set data_dir E:\xampp\php\pear
pear config-set test_dir E:\xampp\php\pear
pear config-set www_dir E:\xampp\php\pear
E:\xampp\php>

E:\xampp\php>pear config-set doc_dir E:\xampp\php\pear
config-set succeeded

E:\xampp\php>pear config-set cfg_dir E:\xampp\php\pear
config-set succeeded

E:\xampp\php>pear config-set data_dir E:\xampp\php\pear
config-set succeeded

E:\xampp\php>pear config-set test_dir E:\xampp\php\pear
config-set succeeded

E:\xampp\php>pear config-set www_dir E:\xampp\php\pear
config-set succeeded

E:\xampp\php>pear install PHP_CodeSniffer
WARNING: channel "pear.php.net" has updated its protocols, use "pear channel-upd
ate pear.php.net" to update
downloading PHP_CodeSniffer-2.0.0.tgz ...
Starting to download PHP_CodeSniffer-2.0.0.tgz (448,559 bytes)
.............................done: 448,559 bytes
install ok: channel://pear.php.net/PHP_CodeSniffer-2.0.0

E:\xampp\php>

Now it works !! 🙂

7 thoughts on “ERROR: failed to mkdir C:\php\pear\tests\PHP_CodeSniffer\CodeSniffer\Core\File [Solved]”

  1. Warning: mkdir(): Permission denied in /Applications/XAMPP/xamppfiles/htdocs/php254/lecture25 2015.03.26/project/topics/file_upload/process_upload.php on line 130
    failed to create folder users

    I have big problem for mac for above

  2. I had the same error ‘failed to mkdir C:\php\pear\tests\PHP_CodeSniffer\CodeSniffer\Core\File’ but setting the pear config did not work for me, it would still try to install in C:\php instead of C:\xampp\php. It took me some time to find the solutiuon so I will post it here in case others have the same problem:

    Run your terminal window as administrator
    Apparently, if you dont, the commands pear config-set will not work. So after I ran my command window as administrator I went to c:\xampp\php and ran the commands:

    pear config-set doc_dir C:\xampp\php\pear\docs
    pear config-set cfg_dir C:\xampp\php\pear\cfg
    pear config-set data_dir C:\xampp\php\pear\data
    pear config-set man_dir C:\xampp\php\local\man
    pear config-set test_dir C:\xampp\php\pear\tests
    pear config-set www_dir C:\xampp\php\pear\www

    pear install PHP_CodeSniffer

    Finally it worked.

Leave a Reply