我正在使用Ubuntu 16.04并试图安装Laravel(任何版本)。实际上,我从GitHub克隆了Laravel项目(https://github.com/laravel/laravel)克隆后,我运行命令如下:
root:/var/www/html/laravel$ composer install
Loading composer repositories with package information
Updating dependencies (including require-dev)
Authentication required (packagist.org):
Username:
这是我面临的问题,我不知道我要给什么用户名,为什么它要求认证…如果我运行composer diagnose
,我得到这样的输出:
composer diagnose
Checking composer.json: OK
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: Authentication required (packagist.org):
Username:
有什么建议或者谁能告诉我在这里错过了什么?
运行composer config --global repo.packagist composer https://packagist.org
然后再试一次。这应该防止它使用http协议和强制https,这可能会在你有一个坏代理的情况下修复它。
在我的情况下,解决问题如下:
$ composer diagnose
Checking composer.json: OK
Checking platform settings: OK
Checking git settings: OK
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com rate limit: OK
Checking disk free space: OK
Checking pubkeys: FAIL
Missing pubkey for tags verification
Missing pubkey for dev verification
Run composer self-update --update-keys to set them up
Checking composer version: WARNING
You are not running the latest stable version, run `composer self-update` to update (1.6.3 => 1.7.2)
Composer version: 1.6.3
PHP version: 7.2.8
PHP binary path: /usr/local/Cellar/php/7.2.8/bin/php
我跑了
$ composer self-update --update-keys
Open https://composer.github.io/pubkeys.html to find the latest keys
Enter Dev / Snapshot Public Key (including lines with -----):
[copy and paste the dev pub key]
Enter Tags Public Key (including lines with -----):
[copy and paste the tags pub key]
然后,我又跑了
$ composer self-update
但是,在安装包时,它仍然显示:
Authentication required (repo.packagist.org):
Username:
在为我的packagist.org帐户提供了我的用户名和密码并将我的凭据存储在/Users/xxx/.composer/auth.json
后,问题解决了。
尝试先在您的CLI上运行这个composer config --global repo.packagist composer https://packagist.org