今天我想启动我旧的基于 Symfony Flex 的项目(我前段时间已经在本地删除了 docker 容器/图像/缓存)。 启动容器时,在入口点,
composer
应该安装所有依赖项,但它失败了。
我已经启动了该项目,但没有安装依赖项,因此我可以手动运行它,但奇怪的事情发生了。
Composer 无法下载食谱 index.json
文件,而我可以使用 curl 来下载。
这里是
composer
日志:
# composer update symfony/flex
In CurlDownloader.php line 623:
The "https://raw.githubusercontent.com/symfony/recipes-contrib/flex/main/index.json" file could not be downloaded (HTTP/2 404 )
update [--with WITH] [--prefer-source] [--prefer-dist] [--prefer-install PREFER-INSTALL] [--dry-run] [--dev] [--no-dev] [--lock] [--no-install] [--no-audit] [--audit-format AUDIT-FORMAT] [--no-autoloader] [--no-suggest] [--no-progress] [-w|--with-dependencies] [-W|--with-all-dependencies] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--apcu-autoloader-prefix APCU-AUTOLOADER-PREFIX] [--ignore-platform-req IGNORE-PLATFORM-REQ] [--ignore-platform-reqs] [--prefer-stable] [--prefer-lowest] [-i|--interactive] [--root-reqs] [--] [<packages>...]
这是卷曲:
# curl -IL --http2 https://raw.githubusercontent.com/symfony/recipes/flex/main/index.json
HTTP/2 200
cache-control: max-age=300
content-security-policy: default-src 'none'; style-src 'unsafe-inline'; sandbox
content-type: text/plain; charset=utf-8
etag: "cbf7d5d470e448beeb667739f56cc627eb271aa54de7d1a46d10eb8ee72ddc36"
strict-transport-security: max-age=31536000
x-content-type-options: nosniff
x-frame-options: deny
x-xss-protection: 1; mode=block
x-github-request-id: D29A:D902:9C967E:ACDA5B:63B2C9F7
accept-ranges: bytes
date: Mon, 02 Jan 2023 13:47:19 GMT
via: 1.1 varnish
x-served-by: cache-fra-eddf8230085-FRA
x-cache: HIT
x-cache-hits: 1
x-timer: S1672667240.634749,VS0,VE1
vary: Authorization,Accept-Encoding,Origin
access-control-allow-origin: *
x-fastly-request-id: aac3282f232b3395c82294f6b70b799be6586a24
expires: Mon, 02 Jan 2023 13:52:19 GMT
source-age: 74
content-length: 73467
我运行了
composer diagnose
命令:
# composer diagnose
Checking composer.json: WARNING
require.symfony/one-signal-notifier : exact version constraints (6.1.x-dev) should be avoided if the package follows semantic versioning
Checking platform settings: OK
Checking git settings: OK git version 2.38.2
Checking http connectivity to packagist: OK
Checking https connectivity to packagist: OK
Checking github.com oauth access: The oauth token for github.com seems invalid, run "composer config --global --unset github-oauth.github.com" to remove it
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: OK
Composer version: 2.5.1
PHP version: 8.1.13
PHP binary path: /usr/local/bin/php
OpenSSL version: OpenSSL 3.0.7 1 Nov 2022
cURL version: 7.86.0 libz 1.2.13 ssl OpenSSL/3.0.7
zip: extension present, unzip present, 7-Zip not available
TL;博士 检查您是否为 github/gitlab 或项目中的其他服务配置了自定义身份验证。它可能已过时并可能导致上述问题。就我而言,它是在
auth.json
文件中配置的。
故事模式:
我注意到了
The oauth token for github.com seems invalid, run "composer config --global --unset github-oauth.github.com" to remove it
。这是我唯一的线索。
我尝试运行
composer config --global --unset github-oauth.github.com
命令,但它没有改变任何内容,所以我忽略了它。
过了一段时间,试图弄清楚它(并在服务器上运行
composer install
)我注意到一个auth.json
文件添加到存储库中。该文件似乎包含我们前段时间使用的自定义包所需的过时的 GitHub OAuth 密钥。
从那时起,我们的 PR 被合并到官方包中,我们的版本不再使用,但我们没有删除旧的 auth.json
文件。
编辑: 现在在 Github 中,您可以生成有效期长达 1 年的细粒度代币。
我在github操作中遇到了dependabot同样的问题。
幸运的是,经过几个小时的搜索,我发现了你的帖子,原因是相同的,作曲家使用了错误配置的 github 密钥。
我更新了秘密值,一切正常!
非常感谢!