Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Composer fails to self-update

When I try to run composer self-update, I get the error:

The file is corrupted (creating archive "/home/heytherejake/.composer/cache/composer-temp.phar" disabled by the php.ini setting phar.readonly).
Please re-run the self-update command to try again.

I have set phar.readonly set to Off (and my phpinfo reflects this), yet the error still occurs. Does anyone know what else might cause this?

like image 675
Jake Roussel Avatar asked Apr 15 '14 19:04

Jake Roussel


People also ask

How do I update composer to latest version?

update / u / upgrade# In order to get the latest versions of the dependencies and to update the composer. lock file, you should use the update command. This command is also aliased as upgrade as it does the same as upgrade does if you are thinking of apt-get or similar package managers.

How do you solve a composer error?

To solve the Memory exhausted issue, you can try running composer with an Unlimited memory flag like this: php -d memory_limit=-1 /usr/local/bin/composer [COMMAND] or php -d memory_limit=-1 composer. phar [COMMAND] when using a local composer. If that doesn't help, you can upgrade your hosting plan.

Why is composer not working?

Try clearing Composer's cache by running composer clear-cache . Ensure you're installing vendors straight from your composer. json via rm -rf vendor && composer update -v when troubleshooting, excluding any possible interferences with existing vendor installations or composer. lock entries.


2 Answers

The best solution is to remove composer and then reinstall it:

i. Find Composer:

which composer

ii. Then remove it as sudo (use the directory returned from above)

sudo rm -rf /usr/local/bin/composer
sudo rm -rf ~/.composer/cache/

iii. Then install it using apt-get

sudo apt-get update
sudo apt-get install curl php5-cli git
curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

iv. Then test if it's working

composer self-update
like image 129
Paulo Pereira Avatar answered Sep 20 '22 16:09

Paulo Pereira


Composer not updating or working properly is usually due to one of two things. Bad permission and/or bad cache.

To Remove cache, use sudo rm -rf ~/.composer/cache/

To fix permission issue change composer.phar permission to 755:

which composer
sudo chmod 755 path/to/composer

as a last mean of fixing this issue, try to update with sudo sudo -H composer self-update

like image 38
NMC Avatar answered Sep 20 '22 16:09

NMC