9

I installed laravel/homestead and tried 'composer update'. Composer gives me an TransportException about a private repo.

Composer update
Loading composer repositories with package information
Your GitHub credentials are required to fetch private repository metadata (https://github.com/GrahamCampbell/asset)
A token will be created and stored in "/home/vagrant/.composer/auth.json", your password will never be stored
To revoke access to this token you can visit https://github.com/settings/applications
Username:
Password:
Token successfully created
[Composer\Downloader\TransportException]
The "https://api.github.com/repos/GrahamCampbell/asset" file could not be downloaded (HTTP/1.1 404 Not Found)

I can't pass this point so I'm stuck.

Bahjaat
  • 101
  • 1
  • 5
  • Just to be clear, is this repository private? – A.L Mar 29 '15 at 22:46
  • Looking at GrahamCampbell at Github [link](https://github.com/GrahamCampbell?tab=repositories) I can't find as 'asset' repository. I guess it 's a private, but I will believe it totally won't exists anymore because of the 404. Am I right? – Bahjaat Mar 30 '15 at 06:21
  • Here's a quick shortcut to [GrahamCampbell's repository at Github](https://github.com/GrahamCampbell?tab=repositories) – Bahjaat Mar 30 '15 at 06:29

1 Answers1

7

If you have access to the private repo, you can use SSH Keys in composer.

Otherwise you can use GitHub API Tokens.

$ export GITHUB_ACCESS_TOKEN=hash-to-your-api-token
$ composer config -g github-oauth.github.com $GITHUB_ACCESS_TOKEN
$ composer install

If you are using Vagrant, you can add an environment variable and the composer configuration in your provisioner.

At the moment of writing the page to generate a new access token on GitHub can be found under Settings / Developer settings / Personal access tokens.

Francesco Casula
  • 26,184
  • 15
  • 132
  • 131
acfreitas
  • 1,347
  • 2
  • 13
  • 27
  • 1
    But 'token' is successfully created (after entering 'username' and 'password'). Authorization should be ok then, right? I also I don't have access to the private repository from GrahamCampbell. – Bahjaat Mar 30 '15 at 14:49
  • @Bahjaat, you can create a new token in GitHub and configure in your composer. For more information, see in [github help](https://help.github.com/articles/which-remote-url-should-i-use/#cloning-with-https-recommended) and this [article](https://codeship.com/documentation/languages/php/#github-api). This will authenticate in github. > If you have two-factor authentication enabled, you must create a personal access token to use instead of your GitHub password. > You can use a credential helper so Git will remember your GitHub username and password every time it talks to GitHub. – acfreitas Mar 30 '15 at 14:55
  • Remember, in this case, you need access in private repository. – acfreitas Mar 30 '15 at 14:56
  • Just restarted (and re-provisioned) Homestead and tried again. No questions anymore about this repository. Got only failures about not been able to copy / move from cache. Did see there was the 'root' user that was owner of the cache-directory. Suppose that I used the 'sudo' to much while updating composer. Just did a reset with 'chown' of the 'cache'-folder and I'm back in business. Thank you all for thinking with me, should I accept an answer right know (newbie)? – Bahjaat Mar 30 '15 at 19:31