Search code examples
laravel

My composer give me mkdir() permission denied exception


I have run

composer create-project --prefer-dist laravel/laravel blog

this command in htdocs cmd. It worked several times. But now its giving me mkdir() permission denied Error. Why is that??

It should have created a file named Project_mig! I wonder what went wrong. :(

enter image description here


Solution

  • You are trying to run this command in your Windows installation folder which you don't have permission to write.

    You can see this from the command line

    C:\WINDOWS\System32>
    

    The solution would be cd to other folder or drive that you have permission to write (ex: D Drive) and run the command again.

    Example:

    D:
    
    cd D:/Projects // Might be different based on your folder structure
    
    composer create-project --prefer-dist laravel/laravel blog
    

    Because you said the same command works on Git Bash. That is because Git Bash default folder is ~ which points to current user folder in your system. Because it is your own user folder, you can do anything there including write. That's why your script works fine using Git Bash.