patrickmaciel's avatar

composer laravel installer permission denied on Windows 10

Hi guys how are you? Tody I start work on Windows 10 again (previous was MacOS High Sierra). And when I tried execute the command composer global require laravel/installer I received the following error:

Changed current directory to C:/Users/patri/AppData/Roaming/Composer


  [ErrorException]
  file_put_contents(C:\Users\patri\AppData\Roaming\Composer\vendor): failed to open stream: Permission denied


require [--dev] [--prefer-source] [--prefer-dist] [--no-progress] [--no-suggest] [--no-update] [--no-scripts] [--update-no-dev] [--update-with-dependencies] [--update-with-all-dependencies] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--] [<packages>]...
0 likes
17 replies
diegoaurino's avatar

Hello, @patrickmaciel !

I hope you installed Composer via the official ".exe" installer as @jlrdw suggested. But besides that, you also need to include the vendors/bin folder in your user path variable if you want to run the packages .bat from PowerShell or CMD with ease.

Go to system properties -> Advanced -> Environment Variables. In the variables for you user, append to the "path" variable something like %USERPROFILE%\AppData\Roaming\Composer\vendor\bin

If you did a custom/script installation, you need to define the COMPOSER_HOME variable as well. Look at the docs: https://getcomposer.org/doc/03-cli.md#composer-home

Let me know if it helps.

1 like
patrickmaciel's avatar

@DIEGOAURINO - yes, I already do that. But the error was gone after 3 hours doing the same command... Im think is a problem in the package repositories... I dont know, it's really gone and the only thing I do is, install and reinstall 20 times.

patrickmaciel's avatar

Guys, after hours and hours trying to solve that problem... I install and reinstall 20 times or more, but nothing solve.

But, after some attempts, just worked.

I dont know what happen, serioulsy.

patrickmaciel's avatar

And happening again =( Man... in my old Macbook works great.... now in Windows 10, dear lord. I dont know what to do.

Look that: Im on the project folder, with composer.json, everythings ok with files, but the error is on the AppData composer/vendor folder... I dont understand.

PS C:\Users\patri\www\......i> composer update -vvv
Reading C:/Users/patri/AppData/Roaming/Composer/composer.json
Loading config file C:/Users/patri/AppData/Roaming/Composer/composer.json
Checked CA file C:\Users\patri\AppData\Local\Temp\ope779B.tmp: valid
Executing command (C:/Users/patri/AppData/Roaming/Composer): git branch --no-color --no-abbrev -v
Executing command (C:/Users/patri/AppData/Roaming/Composer): git describe --exact-match --tags
Executing command (C:/Users/patri/AppData/Roaming/Composer): git log --pretty="%H" -n1 HEAD
Executing command (C:/Users/patri/AppData/Roaming/Composer): hg branch
Executing command (C:/Users/patri/AppData/Roaming/Composer): fossil branch list
Executing command (C:/Users/patri/AppData/Roaming/Composer): fossil tag list
Executing command (C:/Users/patri/AppData/Roaming/Composer): svn info --xml
Reading C:/Users/patri/AppData/Roaming/Composer/composer.json
Loading config file C:/Users/patri/AppData/Roaming/Composer/composer.json
Reading C:/Users/patri/AppData/Roaming/Composer/vendor/composer/installed.json
Reading C:/Users/patri/AppData/Roaming/Composer/vendor/composer/installed.json
Running 1.8.5 (2019-04-09 17:46:47) with PHP 7.2.18 on Windows NT / 10.0
Reading C:/Users/patri/AppData/Roaming/Composer/composer.json
Loading config file C:/Users/patri/AppData/Roaming/Composer/composer.json
Executing command (C:/Users/patri/AppData/Roaming/Composer): git branch --no-color --no-abbrev -v
Executing command (C:/Users/patri/AppData/Roaming/Composer): git describe --exact-match --tags
Executing command (C:/Users/patri/AppData/Roaming/Composer): git log --pretty="%H" -n1 HEAD
Executing command (C:/Users/patri/AppData/Roaming/Composer): hg branch
Executing command (C:/Users/patri/AppData/Roaming/Composer): fossil branch list
Executing command (C:/Users/patri/AppData/Roaming/Composer): fossil tag list
Executing command (C:/Users/patri/AppData/Roaming/Composer): svn info --xml
Reading C:/Users/patri/AppData/Roaming/Composer/composer.json
Loading config file C:/Users/patri/AppData/Roaming/Composer/composer.json
Reading C:/Users/patri/AppData/Roaming/Composer/vendor/composer/installed.json
Reading C:/Users/patri/AppData/Roaming/Composer/vendor/composer/installed.json
Composer could not find the config file: C:\Users\patri\AppData\Roaming\Composer\vendor
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
yogeshMore's avatar

The same issue was found with laravel 10. X. X (latest version). Need to update the composer but "Windows 10" and above do not allow commands like "composer self-update". So I downloaded a new composer.exe from the web https://getcomposer.org/download/ and installed it again(without removing the older one), It'll update automatically and it worked.

ferdmusic's avatar

I am sorry to reopen this but has anyone found a reason on why this is happening? With the latest version of Composer I am running into the same issue.

C:\xampp\htdocs\dashboard\Laravel-minewache>composer install
Composer could not find the config file: C:\ProgramData\ComposerSetup\bin
To initialize a project, please create a composer.json file. See #Link(I can't include it as I am newly registered)

C:\xampp\htdocs\dashboard\Laravel-minewache>composer self-update
You are already using the latest available Composer version 2.7.7 (stable channel).

C:\xampp\htdocs\dashboard\Laravel-minewache>composer require laravel/laravel

In RequireCommand.php line 155:

  file_put_contents(C:\ProgramData\ComposerSetup\bin): Failed to open stream: Permission denied


require [--dev] [--dry-run] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--fixed] [--no-suggest] [--no-progress] [--no-update] [--no-install] [--no-audit] [--audit-format AUDIT-FORMAT] [--update-no-dev] [-w|--update-with-dependencies] [-W|--update-with-all-dependencies] [--with-dependencies] [--with-all-dependencies] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-m|--minimal-changes] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--] [<packages>...]


C:\xampp\htdocs\dashboard\Laravel-minewache>

ferdmusic's avatar

@Tray2 Thank you for that quick answer! This was also what I thought as the XAMPP installation also stated something similar (UAD Permissions). That's why I changed the composer installation to the directory you suggested. Now I still have another problem and I don't know if I am just the one not understanding composer or if it is acting weird for me. When I am cd'd into my project directory and do something with composer it seems to want to go to its installation path. From my understanding it is susposed to install the dependecies/look for the composer.json in the current directory. It seems to not be doing that.

Composer could not find the config file: C:\xampp\composer\bin
To initialize a project, please create a composer.json file. See #Link/basic-usage
PS C:\xampp\htdocs\dashboard\Laravel-minewache> composer install --working-dir=.
Composer could not find the config file: C:\xampp\composer\bin
To initialize a project, please create a composer.json file. See #Link/basic-usage
PS C:\xampp\htdocs\dashboard\Laravel-minewache>
PS C:\xampp\htdocs\dashboard\Laravel-minewache> dir


    Verzeichnis: C:\xampp\htdocs\dashboard\Laravel-minewache


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----        11.08.2024     19:45                .idea
d-----        09.08.2024     12:41                app
d-----        09.08.2024     12:41                bootstrap
d-----        09.08.2024     12:41                config
d-----        09.08.2024     12:41                database
d-----        09.08.2024     14:58                node_modules
d-----        09.08.2024     12:41                public                                                                                                                                                                                                                                                                                                                                                                                                                                                           
d-----        09.08.2024     12:41                resources
d-----        09.08.2024     12:41                routes
d-----        09.08.2024     12:41                storage
d-----        09.08.2024     12:41                tests
-a----        09.08.2024     12:41           1024 ..env.swp
-a----        09.08.2024     12:41            258 .editorconfig
-a----        09.08.2024     12:41           1077 .env.example                                                                                                                                                                                                                                                                                                                                                                                                                                                     
-a----        09.08.2024     12:41            186 .gitattributes
-a----        09.08.2024     12:41            258 .gitignore
-a----        09.08.2024     12:41            350 artisan
-a----        09.08.2024     12:41           2070 composer.json
-a----        09.08.2024     12:41         307986 composer.lock
-a----        09.08.2024     14:58         105740 package-lock.json
-a----        09.08.2024     12:41            429 package.json
-a----        09.08.2024     12:41           1191 phpunit.xml
-a----        09.08.2024     12:41             93 postcss.config.js
-a----        09.08.2024     12:41           4109 README.md
-a----        09.08.2024     12:41            656 tailwind.config.js
-a----        09.08.2024     12:41            310 vite.config.js


PS C:\xampp\htdocs\dashboard\Laravel-minewache> composer require laravel/jetstream

In RequireCommand.php line 155:
                                                                                      
  file_put_contents(C:\xampp\composer\bin): Failed to open stream: Permission denied  
                                                                                      

require [--dev] [--dry-run] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--fixed] [--no-suggest] [--no-progress] [--no-update] [--no-install] [--no-audit] [--audit-format AUDIT-FORMAT] [--update-no-dev] [-w|--update-with-dependencies] [-W|--update-with-all-dependencies] [--with-dependencies] [--with-all-dependencies] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-m|--minimal-changes] [--sort-packages] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--] [<packages>...]
Tray2's avatar

@ferdmusic not using windows but I would guess you need to copy all files to that directory

jlrdw's avatar

@ferdmusic I have never had these problems with composer, you tell composer where the php folder is during installation.

ferdmusic's avatar

@jlrdw @tray2 thanks for your help :) I suspected it was a problem with my Windows setup and switched to Linux. Now it works perfectly.

Please or to participate in this conversation.