🔖
LaravelをインストールしようとしたらTokenが求められた話
はじめに
Laravel環境構築するぞ、ってことでインストールをしました。
composer create-project laravel/laravel sample_laravel_project "6.*"
すると
Could not fetch https://api.github.com/repos/symfony/polyfill-php72/zipball/9a142215a36a3888e30d0a9eeea9766764e96976, please review your configured GitHub OAuth token or enter a new one to access private repos
Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+MaotouyingnoMacBook-Air.local+2021-11-24+0512
to retrieve a token. It will be stored in "/Users/Grune/.composer/auth.json" for future use by Composer.
Token (hidden):
ん?これはなんぞや?ということで調べました。
環境
- macOS Monterey 12.0.1
- Laravel Framework 6.20.6
状況把握
インストールをよく見るとなんかはじめからTokenについて言ってやがる。
そんでもってどうやらインストールがうまく行っていないのは polyfill-php73 ってヤツみたい。
You can also add it manually later by using "composer config --global --auth github-oauth.github.com <token>"
Failed to download symfony/polyfill-php73 from dist: Could not authenticate against github.com
Now trying to download from source
- Syncing symfony/polyfill-php73 (v1.23.0) into cache
1/62 [>---------------------------] 1%
こんな記事を発見。
ComposerがダウンロードのためにGitHub APIってのを使っているみたい。
そのGitHub APIのレート制限に引っかかり、GitHub APIに匿名でアクセスできなくなったためにTokenが求められるそう。つまりGitHub側の問題。
じゃあTokenの発行が必要ですね。
個人アクセスTokenの発行
以下を参考にTokenを発行します。
よしゃ、発行できた。
これを後は入力するだけ。
Token (hidden):
Token stored successfully.
Could not fetch https://api.github.com/repos/php-fig/container/zipball/513e0666f7216c7459170d56df27dfcefe1689ea, please review your configured GitHub OAuth token or enter a new one to access private repos
Head to https://github.com/settings/tokens/new?scopes=repo&description=Composer+on+MaotouyingnoMacBook-Air.local+2021-11-24+0518
to retrieve a token. It will be stored in "/Users/Grune/.composer/auth.json" for future use by Composer.
Token (hidden):
ん?「Token stored successfully.」って言ってるのにダメなの?
やり直し
ちょっと何回やってもダメなので一旦 Ctrl+C でインストール中断。
もう一回インストールをやり直すよ。
composer create-project laravel/laravel sample_laravel_project "6.*"
いや出来たわ。
まとめ
正直記事にする程無いくらい簡単に終わってしまった。
でもなんでGitHubが関わってくんだ、とは思ってたからそれが知れたのは収穫。
うまくいかない時はやり直しも大事。
Discussion