Update composer 2
What if you accidentally deleted your “vendor” folder.
On updating composer to 2 I get:
[Composer\Downloader\FilesystemException]
Filesystem exception:
Composer update failed: “/usr/local/bin/composer1.phar” could not be written.
rename(/usr/local/bin/composer1.phar): Failed to open stream: Permission denied
That’s a classic permissions problem — you don’t have write access to /usr/local/bin/ because your hosting account isn’t root.
You won’t be able to overwrite the system-wide Composer binary, but you can install Composer v2 locally just for your user account.
Safe way to upgrade Composer without root
This will leave the server’s system Composer untouched and give you a Composer v2 binary you control.
1. Download Composer v2 to your home folder
php -r "copy('https://getcomposer.org/composer-2.phar', 'composer.phar');"
2. Use it for installs
Instead of:
composer install
Run:
php composer.phar install
You can also run:
php composer.phar require vendor/package
Optional: Make it easier to type
If you want composer to run this new version by default, you can alias it in your shell:
alias composer='php ~/composer.phar'
Add that to your ~/.bashrc or ~/.bash_profile so it’s always active.
💡 Why this works:
We’re bypassing /usr/local/bin/ completely, so no Permission denied issues, and you still get Composer 2’s speed and compatibility.
If you want, I can give you a one-line command to replace your current Composer v1 with v2 only for your user so you can keep typing composer normally without php composer.phar. That’s the smoothest setup.