Programming Joke.

How does a mechanic start their day? They go to work. They get their tools and start working.
How does a carpenter start their day? They go to work. They pick up their tools and begin where they left off the previous day.
How does a web developer start their day? They go to work. Turn on their computer. Start up the needed programs. Discover updates are needed. Start to do the updates. Failures happen. Spend entire day finding every bug and quirk in every piece of software they use. Maybe their OS shit the bed. Maybe their frameworks need updating… So they spend 4 hours googling and fixing errors in the first tool. Get to the next tool, same thing, spend 2 hours fixing it. Get to the next tool and have to spend 4 hours googling, updating and fixing it. In the midst of all of that they wreck a few things and have to restart a few dozen times. Finally 10 hours later their tools are maybe ready for programming the next day.
These days as a web developer you spend more time fixing your tools than programming. Programming in Web languages is the absolute worst of the worst.
If web developers were mechanics we would be ordering new tools every day and waiting for them to arrive before we could start work because the previous days tools were either broken, stolen or worked entirely differently today than they did yesterday… and the manufacturers docs were not updated, so we have to just play with them until we figure out how they work now.

Now to fix the Github issue with composer.
Side note: a long time ago I’d get these types of errors when simply pushing my code to my own repository.
“gitHub API limit (0 calls/hr) is exhausted, could not fetch https://api.github.com/graphql. Create a GitHub OAuth token to go over the API rate limit. You can also wait until ? for the rate limit to reset.”
Aren’t we all just like..

Well the Composer docs say the following
Because of GitHub’s rate limits on their API it can happen that Composer prompts for authentication asking your username and password so it can go ahead with its work.
If you would prefer not to provide your GitHub credentials to Composer you can manually create a token using the procedure documented here.
Now Composer should install/update without asking for authentication.
I don’t know about you, but Composer has never once prompted me for any password. It sort of just started doing this.
Here is what I randomly got today while trying to update a Symfony project.
Calculating CHANGELOG…GitHub API limit (0 calls/hr) is exhausted, could not fetch https://api.github.com/search/issues?q=a1a70353f64f405cfbacfc4ce860af623442d6e5. Create a GitHub OAuth token to go over the API rate limit. You can also wait until ? for the rate limit to reset.
Composer never asked for any authentication password. I do notice this error it is finally prompting for a github token below this error in another message. I have no idea when this began, I used composer a few weeks ago it seems and this wasn’t an issue.
You can enter the token there and it says it saves it. DON’T DO THAT. Stop now. Do not create and enter the token at this prompt or you will be dreadfully sorry, you will get nothing but errors about the malformed token if you do. DON’T DO IT. Hit ctrl+c to quit or close your terminal, but whatever you do, do not enter that token yet, until you have the latest version of Composer installed.
Find your version with
//globally installed composer --verision //or loally installed php composer.phar --version
If your version composer is not the latest version then update it(2.2.9 as of this article) To do this, if you installed composer locally then you delete the composer.phar file in your project folder. If you installed it globally then you need to go to that directory probably in
/usr/local/bin/
composer
where composer is the filename not a directory. Delete the composer file. You will see suggestions online that you can just run those commands and you don’t need to delete composer. That didn’t work for me. I only got permission denied errors instead. So I rage deleted the damn thing and issued the commands again and
El magico

No more permission denied now you summonabich!!! LOL
Then rerun the commands to install composer either locally or globally. I prefer globally so I don’t have to screw around with updating each project.
Then you need to create this special token to use Composer.

How to create and use the token? That is explained in the Composer Docs here. You go to the github page seen below

Don’t choose any of the Scopes, just choose to create this useless token, it doesn’t need them.
You will next see this screen.
Now you copy that token. Open your terminal and use the following command with your token where the word token is.
//locally installed composer php composer.phar config github-oauth.github.com token
//globally installed like I suggested composer config --global github-oauth.github.com token
And now composer should be working again.

Comments
One response to “How to fix Composer GitHub API limit (0 calls/hr) is exhausted … errors”
Just to add my tiny piece of experience: once I installed composer globally (2.4.2 at some time), I bumped into issues with the token after 8 months or so (actual version of composer is 2.4.4 now) and the
composer self-update
command seems to do the job quite seamlessly.You must log in to post a comment.