Reputation: 4705
I have no issue to clone from my local machine of the private repository, however, when I want to download the file via composer it asks me to create an auth.json file (I don't want this and I don't want to use a token).
Do you have an idea why this happens?
composer.json
"require": {
..
"myname/my-app": "*",
..
},
"repositories": [
{
"type": "vcs",
"url": "[email protected]:myname/my-app.git",
},
]
I tried to add "no-api": true
, I tried to set dev-master
but failed. To test it out, I created a repository to BitBucket and with that I have no problems installing it.
My error is:
Loading composer repositories with package information
Failed to download myname/my-app:The "https://gitlab.com/api/v4/projects/myname%2Fmy-app" file could not be downloaded (HTTP/1.1 404 Not Found)
Your credentials are required to fetch private repository metadata ([email protected]/my-app.git)
A token will be created and stored in "/Users/myname/.composer/auth.json", your password will never be stored
To revoke access to this token you can visit gitlab.com/profile/applications
Upvotes: 6
Views: 6914
Reputation: 830
ssh and git now work in composer
Your gitlab clone looks like this:
[email protected]:/.git
Do this in your composer.json:
{
...
"repositories": [
...
{
"type": "git",
"url": "[email protected]:<VENDOR>/<PROJECT>.git"
}
]
}
Then add the resource:
composer require <VENDOR>/<PROJECT>
composer update
Upvotes: 7
Reputation: 1060
We had the same problem some days ago. The problem is that GitLab public Api does not expose the default branch name of the repository that is needed for composer. The only solution we found so far is:
Open you composer.json and add this:
"config": {
"gitlab-token": {
"gitlab.com": "YOUR_TOKEN"
}
},
Run composer install
P.S. Use this solution with care since that token will be stored in the project repository and shared with your team.
Upvotes: 11