Saad_Ibn_Rouf
Saad_Ibn_Rouf

Reputation: 7

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

Upvotes: 0

Views: 2531

Answers (5)

farhad rohani
farhad rohani

Reputation: 1

In general, the following should be done.

In Windows:

  1. Launch the command prompt with administrative privileges: Right-click on the Command Prompt icon and select "Run as administrator" to open a Command Prompt window with administrative access.

  2. Check directory permissions: Ensure that the directory you want to create a new folder in has the necessary write permissions. You can do this by right-clicking on the directory, selecting "Properties," and navigating to the "Security" tab. Make sure the appropriate user has the required permissions for writing.

In Linux:

  1. Use the sudo command: Instead of running the Composer command with a regular user account, use the sudo command to gain administrative access. For example, sudo composer install.

  2. Check directory permissions: Verify the required permissions for the current user on the target directory. Ensure that you have permission to write to the directory. If necessary, you can use the chmod command to adjust the directory permissions.

Please note that these translations have been provided for convenience. It's important to refer to the instructions in your preferred language for clarity and accuracy.

Upvotes: 0

Antonio Carlos
Antonio Carlos

Reputation: 11

Well then. I also had problems creating a project using the composer. In this case, the user's access permissions to the project directory were related. In this case, how to use windows, I clicked on the project folder and in the security guide I included the user and gave the necessary permissions. I didn't present the problem anymore.

Upvotes: 1

Adarsh Sharma
Adarsh Sharma

Reputation: 576

First of all mkdir() i.e. making new folder/directory permissions error is because of Lack of permissions at the time of performing the same command

you can create your project in different directory

Upvotes: -1

Zendy
Zendy

Reputation: 774

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.

Upvotes: 1

Ravindu_Dilshan
Ravindu_Dilshan

Reputation: 171

First go to the folder where you want to create the project. Then : do as this After that execute "composer create-project --prefer-dist laravel/laravel blog" code.

Upvotes: 2

Related Questions