Closed griase94 closed 2 years ago
I had to enter an oauth token "once" before I could do certain composer actions against github. Try getting a token and going through it without --no-interaction and enter your token. Composer should keep it. Of course, if you are using multiple machines, this becomes onerous "real quick".
See https://github.com/shivammathur/setup-php#composer-github-oauth which might help.
Adding the composer token to the environment (setup-php action) solved it for me:
- uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: xdebug
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
This resolves an authentication error that came unexpected using a different repository than packagist: VCS on Github itself for a public repository of mine:
- run: |
composer config repositories.bugfix vcs https://github.com/ktomk/rector
composer require rector/rector:dev-patch-resolve-classname --no-progress --update-with-dependencies
vendor/rector/rector/bin/rector process --dry-run lib/Collaborator.php 2>&1
I am getting this message time by time, I belive it has to do something with API rate limitting.
Can composer display a better/more relevant message?
this type error ocure how can solve it
[Composer\Downloader\TransportException]
Could not authenticate against github.com
This issue has been automatically marked Stale and will be closed in 15 days if no further activity happens.
This suddenly started happening to me this morning in my CI/CD pipeline. Did something break again?
@jdavidbakr For me as well. Started this morning. I am using Bitbucket Pipelines and composer install stopped with:
Failed to download *package* from dist: Could not authenticate against [github.com](http://github.com/)
@jdavidbakr - me too. I'm wondering if something is down. This has been causing me issues on various repos which had previously passed in pipelines where I have literally just hit re-run and now the issue occurs.
I'm having this happen also on bitbucket pipelines.
same problem here, I'm also using bitbucket pipelines and it started suddenly last night and continues this morning
Seeing this across multiple pipelines and repos. Adding a token seemed to fix it, but this wasn't previously a change that was required.
Would appreciate communication updates
same problem in github action and the token has never been used before
This might work as a temp workaround: https://github.com/composer/composer/issues/8710#issuecomment-604111726
Seems to be working for our setup (much slower though).
Could anyone of those who have the problem please clarify about which token they are talking about and how they provided it to resolve the issue? Where did you obtain the token? Is it just that what was reported last in February?
I'm just asking because providing the token seems legit to me and well documented in case of the authentication failure message or better to prevent it in the first place for remote git receive hooks that spin new build environments (Microsoft Gitub Actions, Atlassian Bitbucket Cloud Pipelines Plugin etc.). Compare for example with the documentation of the Setup PHP Github Action that also installs Composer and has a note extactly on the token about it.
With the exception of major versions of composer, if you specify only the major version or the version in major.minor format for a tool you can get rate limited by GitHub's API. To avoid this, it is recommended to provide a GitHub OAuth token. You can do that by setting
GITHUB_TOKEN
environment variable. (ref)
And more specifically: (ref)
GitHub Composer Authentication If you have a number of workflows which set up multiple tools or have many composer dependencies, you might hit the GitHub's rate limit for composer. Also, if you specify only the major version or the version in major.minor format, you can hit the rate limit. To avoid this you can specify an OAuth token by setting GITHUB_TOKEN environment variable. You can use GITHUB_TOKEN secret for this purpose.
Despite this is related to Gihub Actions, the rate-limiting mentioned is independent and applies both locally as well as remotely, e.g. in Pipelines. Hope this helps to clarify and show that this likely is the case and perhaps the rate limiting got sharper.
Back a couple of years ago it also worked for me without a token. But then one day the internet broke down (Github had a rate-limit misconfiguration IIRC) and since then I'm using the token.
Next to that there were some changes on Github in regard to logins recently, maybe this is related? Has anyone of you contacted Github as it seems they now require the token for yours while they didn't beforehand and therefore why not also ask them as they run the service Composer is authenticating against (if even). If they report an important change back to you, please share here all the clarifications so that it can be done in a good way and everyone can benefit from the information and further improvements.
I have always provided a token in my CI/CD, injecting it as a variable and have this step in the Jenkinsfile before the composer install call:
php composer.phar config -g github-oauth.github.com $GITHUB_KEY
I rotated my key to see if that was the issue but am still getting the error and am unable to install the composer packages in Jenkins. My composer install is this:
php composer.phar install --no-interaction --no-progress --prefer-dist
Having issue on my side too:
Failed to download yajra/laravel-datatables-oracle from dist: Could not authenticate against github.com
Step #0 - "Build": Now trying to download from source Step #0 - "Build": 159/164 [===========================>] 96% Failed to download yajra/laravel-datatables-oracle from dist: Could not authenticate against github.com Step #0 - "Build": Step #0 - "Build": Now trying to download from source Step #0 - "Build": Failed to download tymon/jwt-auth from dist: Could not authenticate against github.com Step #0 - "Build": Now trying to download from source Step #0 - "Build": Failed to download lcobucci/jwt from dist: Could not authenticate against github.com Step #0 - "Build": Now trying to download from source Step #0 - "Build": Failed to download namshi/jose from dist: Could not authenticate against github.com Step #0 - "Build": Now trying to download from source Step #0 - "Build": Failed to download superbalist/laravel-google-cloud-storage from dist: Could not authenticate against github.com Step #0 - "Build": Now trying to download from source Step #0 - "Build": Failed to download league/flysystem-cached-adapter from dist: Could not authenticate against github.com Step #0 - "Build": Now trying to download from source Step #0 - "Build": Failed to download superbalist/flysystem-google-storage from dist: Could not authenticate against github.com Step #0 - "Build": Now trying to download from source Step #0 - "Build": Failed to download simplehtmldom/simplehtmldom from dist: Could not authenticate against github.com Step #0 - "Build": Now trying to download from source Step #0 - "Build": Failed to download sentry/sentry-laravel from dist: Could not authenticate against github.com Step #0 - "Build": Now trying to download from source Step #0 - "Build": Failed to download sentry/sentry from dist: Could not authenticate against github.com Step #0 - "Build": Now trying to download from source Step #0 - "Build": Failed to download symfony/http-client from dist: Could not authenticate against github.com Step #0 - "Build": Now trying to download from source Step #0 - "Build": Failed to download symfony/http-client-contracts from dist: Could not authenticate against github.com Step #0 - "Build": Now trying to download from source
Many repos and libraries are down.
@anthony-munozm: Are you using a token, did you use a token previously? and where did you obtain the token?
I am absolutely okay with needing to add a token, but would like this communicated, since it caused all of our processes to fail overnight. Not the kind of early morning phone calls I like to get..
Well, composer did not changer anything to require a token. But maybe github change the rate limiting rules.
@j-fulbright: Yes when this happens unplanned and it affects distributed automated systems, and then perhaps quite some of it, it can be very cumbersome. So thanks for communicating with others. What I wonder a bit about is whether or not a token was in use as what jdavidbakr commented 21 minutes ago seems to suggest that the issue is currently also appearing with a token. [not the case, it looks like that is was a problem to configure the token, the token does work]
In the past it helped to contact Github support and it then took ca. three hours.
@anthony-munozm: Are you using a token, did you use a token previously? and where did you obtain the token?
no sir @ktomk , i did not use a token for github because my pipelines are using bitbucket, so having a token for libraries that are just dependencies on another git provider makes not sense, but if that is the only solution we would explore it.
I would say this is an issue that would be probably fixed soon by composer devs
@anthony-munozm: This is for Composer downloading from Github.com, this is not a git provider. Git providers you would need to integrate with Bitbucket directly, this is just Composer sending network requests. Compare you're using file_get_contents(https://...) and it returns false because the HTTP code is 403 and by default this turns into false. Would you then sit there and say: Well the PHP core devs will fix file_get_contents() soon? I rather guess not... . So perhaps it's better you try with the token at least in one pipeline to see if it works instead of waiting for "the composer devs" whoever that is.
@anthony-munozm: This is for Composer downloading from Github.com, this is not a git provider. Git providers you would need to integrate with Bitbucket directly, this is just Composer sending network requests. Compare you're using file_get_contents(https://...) and it returns false because the HTTP code is 403 and by default this turns into false. Would you then sit there and say: Well the PHP core devs will fix file_get_contents() soon? I rather guess not... . So perhaps it's better you try with the token at least in one pipeline to see if it works instead of waiting for "the composer devs" whoever that is.
Well, passing a token for a third party that my project is not requiring directly is not a good solution neither and add extra layer of issues for future. This is something that should not happen. If this is not on composer side, then it is on github side. But hundreds of users are affected, you cannot just say... "hey guys, add tokens"
I was able to get it to run with the GitHub token by adding su docker
to the commands ... so either it's been resolved, or I was unsuccessfully attaching the token previously and it just didn't ever complain.
@jdavidbakr That sounds that the config command couldn't store it. You can verify that in config.json / composer.json within COMPOSER_HOME (composer config --global home
) and also verify everything is in order for a non-su workflow (or consider docker secrets, don't know how you run your build pipeline there). /E: And thanks for the update.
@anthony-munozm your project downloads packages from github because many packages available on packagist.org are hosted on github. And adding an authentication token is actually the solution due to the way the github rate-limiting works: authenticated calls have a per-user rate limit. Unauthenticated calls have a per-IP rate limit that is hundred times lower.
I'm getting the same issue.
@anthony-munozm your project downloads packages from github because many packages available on packagist.org are hosted on github. And adding an authentication token is actually the solution due to the way the github rate-limiting works: authenticated calls have a per-user rate limit. Unauthenticated calls have a per-IP rate limit that is hundred times lower.
Allright sir @stof, i will wait few more hours, i am not on a rush. If you suggest that is the best and only solution on short term (1-7 days) i will follow it. Appreciate all your help guys and team.
Btw, this is working now and i did nothing more than just retry, so that confirmed it is rate limit issue on github. :)
This still isn't working through CircleCI.
As said in some previous comments, it's possible to increase the GitHub rate limiting during composer install
by authenticating with a personal access token:
GITHUB_TOKEN=your_token
composer install
. For instance: composer config --global github-oauth.github.com $GITHUB_TOKEN
composer install
and it should not hit any rate limits.Note: Before this morning we were not using any token in our CI for composer / GitHub auth, it seems like the rate limit has been lowered by GitHub or something else has been changed but we never had to be authenticate before today for performing a composer install
.
@qboot Thanks for sharing and the detailed explanation. IIRC there is also the COMPOSER_AUTH
environment variable.
Same problem here started today morning. Thank you @qboot
I hope some of you have notified GitHub support of this instead of just ranting here, because there is literally nothing we can do to help fix this.
I've had 2 repos pass this morning that were failing. I've not made any changes so maybe the issue is fixed?
@cwillhelm-roofr
That's why it would have been nice to have some communication around this.
Please raise this with GitHub support.
Additionally, if it's an intermittent issue or misconfiguration of the rate-limiting on the Github side, and it "fixes itself" -- all of our work and setbacks regarding updating our pipelines would have been pointless.
No, it won't have been pointless. You'll be subject to a different (higher, unaffected by other users) rate limit - thus safeguarding you against any future changes to the unauthenticated (lower, per-IP) rate-limit.
I got this reply, should be fixed now?
GitHub (GitHub Support) Oct 6, 2023, 9:45 AM UTC
Hi Barry,
Thank you for reaching out!
We received some reports earlier and a fix was implemented. If you are still seeing an error, can you share with us the IP address where those requests are coming from, so we can have a closer look?
Regards,
Oluwaseun GitHub Support
Thanks to everyone involved. In case this happens again:
composer diagnose
? If not, add it in front to fail fast. It tells you if the environment is affected by Github Rate-Limiting or not (and other things you want to have in your build logs). Let me repeat: Run composer diagnose
. And spread the word about it.composer diagnose
is part of it as well as the Composer troubleshooting guidelines have the API rate limit and OAuth tokens section, too.It's your own decision whether you want to make use of tokens, and your own obligation how to handle failures of remote systems. My pipelines run offline (Shameless self-plug.)
composer diagnose
.@ktomk I am specifying a fine-grained PAT to install a composer package from private repo and I am hitting the Could not authenticate against github.com
nevertheless. I tried to expose the token via COMPOSER_AUTH and via setting the token in the CLI, but no luck. Do I need to use a fully fledged personal access token? Have someone got this working with fine-grained personal access tokens?
See https://github.com/shivammathur/setup-php#composer-github-oauth which might help. @Seldaek How do i authenticate depencdency packages to download defined in composer.json using ssh keys instead of github auth classic pats please ?
When I run this command:
I'm want to install my dependencies using composer install --no-interaction --no-suggest on one stage of my GitHub Action. Unfortunately all installs fail with a Could not authenticate against github.com error.
I get the following output:
Loading composer repositories with package information Installing dependencies (including require-dev) from lock file Package operations: 158 installs, 0 updates, 0 removals