Composer stuck on installing private GitHub repos

I was trying to install some GitHub repos as dependencies using composer. Composer kept getting stuck on installing the private ones.

composer.json:

1
2
3
4
5
6
7
8
9
"repositories": [
    {
        "type": "vcs",
        "url": "git@github.com:inderpreet99/private.git"
    }
],
"require-dev": {
    "inderpreet99/private": "1.0.1"
}

Log:

1
2
3
4
5
6
7
$ composer install
Loading composer repositories with package information
[Composer\Downloader\TransportException]
The "https://api.github.com/repos/inderpreet99/private" file could not be downloaded (HTTP/1.1 404 Not Found)
install [--prefer-source] [--prefer-dist] [--dry-run] [--dev] [--no-dev] [--no-custom-installers] [--no-autoloader] [--no-scripts] [--no-progress] [--no-suggest] [-v|vv|vvv|--verbose] [-o|--optimize-autoloader] [-a|--classmap-authoritative] [--apcu-autoloader] [--ignore-platform-reqs] [--] []...

Solution:

  1. Go to your GitHub profile.
  2. Under Developer Settings > Personal access tokens, generate a new token.
  3. In cli:
    1
    2
    $ export GITHUB_ACCESS_TOKEN="gibberisheaab78ab18285b9something"
    $ composer config -g github-oauth.github.com $GITHUB_ACCESS_TOKEN

Composer should work much more smoothly now.

Leave a Reply

Your email address will not be published. Required fields are marked *