I am running Ubuntu 18.04.6 LTS
I needed to install composer so I installed using the command:
sudo apt-get install composer
But this would install a version of composer that would give me the following error when using it:
Fatal error: Uncaught ArgumentCountError: array_merge() does not accept unknown named par ameters in /usr/share/php/Symfony/Component/Console/Descriptor/TextDescriptor.php:205 ubuntu
The composer github notes suggested this error was fixed but I kept encountering it without any real solution that I could find online.
So I uninstalled:
sudo apt-get purge --auto-remove composer
I finally solved the issue by installing using the following alternate method:
curl -sS https://getcomposer.org/installer -o composer-setup.php
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
It said everything was setup right, but composer still wasn't launching globally despite me placing it in /usr/local/bin
So I started to fiddle with it. I stopped my AWS instance and then started it again, ran the above alternate install command again (composer-setup.php) and now composer works globally (To clarify: I didn't try running composer globally immediately after restarting instance; I instead installed again using alternate install method and then tried running it global and it worked).
Now composer is working globally and there's no fatal errors.
Does anyone have a hypothesis on why composer wasn't running globally despite being placed in /usr/local/bin initially but then finally started working globally? Is it possible that stopping and starting my AWS instance with Ubuntu is what solved it? If not, then what actually solved it and why wasn't it working globally in the first place?
composer
from any directory? If so, then most likely/usr/local/bin
was not in your user'sPATH
in the session you were trying in, and logging back in fixed that. We can't know more unless you tell us exactly what was happening before an what error you were getting. – terdon Sep 25 '22 at 11:11