I've installed Composer on Windows 10 using installer, but it doesn't seem to work properly. When I try running composer
in the console, it throws an error:
'""' is not recognized as an internal or external command,
operable program or batch file.
I rebooted my pc twice, run the console as an administrator and checked the PATH variable. It contained the Composer install path (C:\ProgramData\ComposerSetup\bin
), but for some reason it doesn't work. I tried running the composer directly after cd to this folder, and it worked, but it doesn't work otherwise.
'where composer' prints out the following:
C:\OpenServer\modules\php\PHP_7.4\composer.bat
C:\ProgramData\ComposerSetup\bin\composer
C:\ProgramData\ComposerSetup\bin\composer.bat
The first path refers to the folder where the PHP is installed, the second is the executable itself
If I try to run 'C:\ProgramData\ComposerSetup\bin\composer', it works as intended, so the Composer itself is installed correctly
How do I get the PATH variable for Composer work properly?
CodePudding user response:
I deleted the C:\OpenServer\modules\php\PHP_7.4\composer.bat
file, and it worked fine.
This folder is the PHP installation folder, which came packed with a local server that I installed previously. For some reason, it had a broken composer.bat
, and when I was installing Composer, I checked "Add PHP folder to the PATH variable". That is why when I tried to run composer
, it ran the broken file and was throwing a weird error.
Thank you, Álvaro González, for helping me to figure that out!