问题
I am trying to update composer with no luck!
What I have tried:
$ composer self-update
[InvalidArgumentException]
Command "self-update" is not defined.
$ sudo -H composer self-update
[InvalidArgumentException]
Command "self-update" is not defined.
$ sudo apt-get install composer
Reading package lists... Done Building dependency tree Reading state information... Done composer is already the newest version. The following packages were automatically installed and are no longer required: libntdb1 linux-headers-4.2.0-30 linux-headers-4.2.0-30-generic linux-image-4.2.0-30-generic linux-image-extra-4.2.0-30-generic python-ntdb Use 'apt-get autoremove' to remove them. 0 upgraded, 0 newly installed, 0 to remove and 10 not upgraded.
I am trying to self-update composer because I am facing the following each time I try:
$ composer update
Loading composer repositories with package information Updating dependencies (including require-dev) [RuntimeException]
Could not load package rmrevin/yii2-fontawesome in http://packagist.org: [UnexpectedValueException] Could not parse version constraint v4.1 .: Invalid version string "v4.1."
[UnexpectedValueException]
Could not parse version constraint v4.1.: Invalid version string "v4.1."
Any Ideas on how to fix this issue?
My php version is:
php --version
PHP 5.6.11-1ubuntu3.4 (cli) Copyright (c) 1997-2015 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies
My composer version is:
composer --version
Composer version @package_branch_alias_version@ (@package_version@) @release_date@
回答1:
As per @JimL comment I was able to self update composer by:
- Uninstalling Composer from the package manager (apt).
- I installed it according to the official documentation
Now it works as expected.
回答2:
As @Waqleh said, you have to uninstall composer and install it again. First execute:
sudo apt-get remove composer
Then, execute these commands (from https://getcomposer.org/download/):
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('SHA384', 'composer-setup.php') === 'baf1608c33254d00611ac1705c1d9958c817a1a33bce370c0595974b342601bd80b92a3f46067da89e3b06bff421f182') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"
Now move composer.phar to a directory that is in your path (fom https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx):
sudo mv composer.phar /usr/local/bin/composer
And execute composer
from any directory. That's all!
PS: If you're using PHPStorm (or maybe other IDE's) you'll have to close it and open again.
回答3:
install the latest version:
remove the composer: for example ubuntu/debian :
sudo apt-get remove composer
install manual:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
php -r "unlink('composer-setup.php');"
after some time passed, you can update and no need to use sudo prefix:
composer self-update
回答4:
There are some issues with all the above answer with no clear understanding. After my system was crashed and rebooted.
Default composer install with the system package with apt-get it
install 1.6 version which does not given to the default command of
self-upate the composer.phar file- So the solve this issue have manually purge the default composer and Follow this Blog
来源:https://stackoverflow.com/questions/37772798/unable-to-self-update-composer