programing

Composer를 자체 업데이트할 수 없습니다.

newsource 2022. 9. 17. 10:43

Composer를 자체 업데이트할 수 없습니다.

Composer를 업데이트하려고 하는데 잘 안되네요!

내가 시도한 것:

$ composer self-update

[잘못된 인수]예외] 명령어 "self-update"가 정의되어 있지 않습니다.

$ sudo -H composer self-update

[잘못된 인수]예외] 명령어 "self-update"가 정의되어 있지 않습니다.

$ sudo apt-get install composer

패키지 목록을 읽는 중...종속성 트리 구축 완료 상태 정보 읽기...완료된 작곡가는 이미 최신 버전입니다.다음 패키지가 자동으로 설치되었으며 더 이상 필요하지 않습니다. libntdb1 linux-headers-4.2.0-30 linux-headers-4.2.0-30-generic linux-image-4.2.0-extra-4.2.0-generic python-ntdb를 사용하여 패키지를 제거합니다.0 업그레이드, 0 신규 설치, 0 삭제 및 10 미업그레이드.

Composer를 자동 갱신하려고 합니다.그 이유는 매번 다음과 같은 문제가 발생하기 때문입니다.

$ composer update

패키지 정보가 포함된 컴포저 리포지토리 로드 종속성 업데이트(require-dev 포함) [실행 시간]예외] http://packagist.org에서 rmrevin/yi2-supsome 패키지를 로드할 수 없습니다. [Unexpected ValueException] 버전 제약 조건 v4.1을 구문 분석할 수 없습니다. [Unexpected ValueException] 버전 제약 조건 v4.1을 구문 분석할 수 없습니다. 버전 문자열 "v4.1"잘못되었습니다.

이 문제를 해결하려면 어떻게 해야 하나요?

내 PHP 버전은 다음과 같습니다.

php --version

PHP 5.6.11-1ubuntu3.4 (cli) Copyright (c) 1997-2015 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

내 작곡가 버전은:

composer --version

Composer 버전@package_branch_alias_version@(@package_version@)@release_date@

Waqleh가 말했듯이 PHP Composer를 제거하고 다시 설치해야 합니다.먼저 다음을 실행합니다.

sudo apt-get remove composer

그런 다음 다음 다음 명령을 실행합니다.다음 체크섬은 Composer 1.10.13용이지만 번째 줄을 실행하면 최신 Composer(이 답변 편집 시점 2.0.4) 제공되므로 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');"

이제 파일 작성기를 이동합니다.par에서 경로에 있는 디렉토리로 이동합니다(설치 - Linux / Unix / macOS에서):

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

실행하다composer모든 디렉토리에서.그게 다예요!

PS: PhpStorm(또는 다른 IDE)을 사용하고 있는 경우는, 닫았다가 다시 열어야 합니다.

Since I posted my answer, I have learnt a new easier way to install Composer programmatically: How do I install Composer programmatically?

Old Answer:


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.

Install the latest version:

Remove your current Composer version, for example Ubuntu/Debian:

sudo apt-get remove composer

Now, head to https://getcomposer.org/download/ and paste the script in your command line. This ensures that you get the latest version of Composer (as time of writing: v2.0.7).

Like this:

php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php -r "if (hash_file('sha384', 'composer-setup.php') === '906a84df04cea2aa72f40b5f787e49f22d4c2f19492ac310e8cba5b96ac8b64115ac402c8cd292b8a03482574915d1a8') { 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 there isn't any need to use the sudo prefix:

composer self-update

It worked for me (linux, Ubuntu 20.04):

sudo apt-get remove composer
sudo apt-get update
sudo apt-get install curl
sudo curl -s https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer

If you have an old version of Composer you need to follow these commands:

composer -V
sudo apt remove composer
cd /tmp
wget http://getcomposer.org/download/1.10.5/composer.phar

php composer.phar -V
sudo mv composer.phar /usr/bin/composer
sudo chmod 750 /usr/bin/composer
composer -V

You can specify the installation directory and filename while setting up PHP Composer - php composer-setup.php like so:

sudo php composer-setup.php --install-dir=/usr/bin --filename=composer

Already there are many answers, Would like to share my experience with this.

I am using Ubuntu 20.04, and My previous Composer version was Composer 2.0.11 and my Project requirement was Composer 2.1.15.

I didn't had to remove anything, I simply used the following command and it worked fine for me :)

Composer Update

I've installed Homebrew and it saves me a lot.

Install brew and then brew install composer to install Composer.

composer 2 on debian :

cd /usr/src

sudo apt-get install curl php7.2-cli

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

chmod 777 composer

nano ~/.bashrc

add : PATH=$PATH/usr/local/bin/

source ~/.bashrc

verify :composer -v

Install the latest Composer by the following steps:

Uninstalling Composer

sudo apt-get remove composer

Run following commands

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

Install Composer in the /usr/bin directory to run Composer from anywhere

sudo php composer-setup.php --install-dir=/usr/bin --filename=composer

Remove the installer

php -r "unlink('composer-setup.php');"

To check or self update

composer self-update

ReferenceURL : https://stackoverflow.com/questions/37772798/unable-to-self-update-composer