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 !! 🙂


Posted

in

by

Tags:

Comments

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

  1. zeeshan Avatar
    zeeshan

    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

    1. Subharanjan Avatar

      Seems like permission issue with the current logged in user. Try with sudo. https://www.linux.com/learn/tutorials/306766:linux-101-introduction-to-sudo

  2. Puffer Avatar
    Puffer

    Thanks you for solution !

  3. Joery Lemmens Avatar
    Joery Lemmens

    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.

    1. ramonamorea Avatar

      Thank you, thank you! After two hours of research, I found your comment. Total life saver; this solution worked for me too. Thanks!

  4. Tran Ngoc Tuan Anh Avatar

    Thanks for your blog post. I’ve just googled for this issue and found your post. Really helpful.

  5. sandeep Avatar
    sandeep

    Thank you so much for the Solution, Exactly same problem i am facing.

Leave a Reply

Your email address will not be published. Required fields are marked *