gpt4 book ai didi

php - 无法 self 更新 Composer

转载 作者:IT王子 更新时间:2023-10-29 00:02:39 24 4
gpt4 key购买 nike

我正在尝试更新 Composer 但没有任何运气!

我尝试过的:

$ 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 Readingstate information... Done composer is already the newest version. Thefollowing packages were automatically installed and are no longerrequired: libntdb1 linux-headers-4.2.0-30linux-headers-4.2.0-30-generic linux-image-4.2.0-30-genericlinux-image-extra-4.2.0-30-generic python-ntdb Use 'apt-getautoremove' to remove them. 0 upgraded, 0 newly installed, 0 to removeand 10 not upgraded.

我正在尝试自行更新 Composer,因为我每次尝试时都会遇到以下问题:

$ composer update

Loading composer repositories with package information Updatingdependencies (including require-dev)[RuntimeException]Could not load package rmrevin/yii2-fontawesome inhttp://packagist.org: [UnexpectedValueException] Could not parseversion constraint v4.1 .: Invalid version string "v4.1."[UnexpectedValueException]Could not parse version constraint v4.1.: Invalid version string"v4.1."

我该如何解决这个问题?

我的 PHP 版本是:

php --version

PHP 5.6.11-1ubuntu3.4 (cli) Copyright (c) 1997-2015 The PHP GroupZend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologieswith Zend OPcache v7.0.6-dev, Copyright (c) 1999-2015, by Zend Technologies

我的 Composer 版本是:

composer --version

Composer version @package_branch_alias_version@ (@package_version@)@release_date@

最佳答案

Waqleh said ,您必须卸载 PHP Composer 并重新安装。首先,执行:

sudo apt-get remove composer

然后,执行这些命令。 此处的校验和适用于 Composer 1.10.13,但在运行第一行时您将获得最新的 Composer(编辑此答案时为 2.0.4),因此请务必 checkin https://getcomposer.org/download/ :

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '8a6138e2a05a8c28539c9f0fb361159823655d7ad2deecb371b04a83966c61223adc522b0189079e3e9e277cd72b8897') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
php composer-setup.php
php -r "unlink('composer-setup.php');"

现在将文件 composer.phar 移动到您路径中的目录(从 Installation - Linux / Unix / macOS ):

sudo mv composer.phar /usr/local/bin/composer

然后从任何目录执行composer。就这样!

PS:如果您使用的是 PhpStorm(或者可能是其他 IDE),则必须将其关闭并再次打开。

关于php - 无法 self 更新 Composer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37772798/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com