Composer found when running directly, but not when running artisan

230 Views Asked by At

I am helping work on a site that uses OctoberCMS. I was trying to update to the latest release, but when I run the Artisan command to update October, I get the following error:

$ php artisan october:update
Updating October CMS...
Executing: composer update

'composer' is not recognized as an internal or external command, operable program or batch file.

[ERROR] Update failed. Check output above

However, if I run composer update directly, it works as expected:

$ composer update
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Nothing to modify in lock file
Installing dependencies from lock file (including require-dev)
Nothing to install, update or remove
Generating autoload files
> System\Console\ComposerScript::postAutoloadDump

   INFO  Discovering packages.

  laravel/tinker .............................................................................. DONE
  nesbot/carbon ............................................................................... DONE
  nunomaduro/termwind ......................................................................... DONE
  october/rain ................................................................................ DONE

94 packages you are using are looking for funding.
Use the `composer fund` command to find out more!
> System\Console\ComposerScript::postUpdateCmd
No security vulnerability advisories found

It has been close to 10 years since I did much PHP development, so my Composer-fu is more than a little rusty. If there is more info needed to help diagnose what's going on, let me know!

Environment:
Windows 11 Pro
Git Bash (running in ConEmu)
PHP 8.1.3
Composer 2.4.4

1

There are 1 best solutions below

0
Ivan Polak On

Can you try running composer in commandline/powershell? (You will likely see the same error)

'composer' is not recognized as an internal or external command, operable program or batch file. Is not a response Git Bash or a linux like terminal would produce.

I think artisan is trying to run composer in a windows shell and can't find it in your PATH, but for some reason you have it in your Git Bash path.