GitLab:Composer使用ssh密钥安装私有存储库(仍然下载失败,下载失败) [英] GitLab: Composer Install private repository with ssh key (still get error failed to download)

查看:71
本文介绍了GitLab:Composer使用ssh密钥安装私有存储库(仍然下载失败,下载失败)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有从我的私有存储库的本地机器克隆的问题,但是,当我想通过composer下载文件时,它要求我创建一个auth.json文件(我不希望这样做,我不希望这样做).不想使用令牌).

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

composer.json

"require": {
..
"myname/my-app": "*",
..
},
"repositories": [
        {
            "type": "vcs",
            "url": "git@gitlab.com:myname/my-app.git",
        },
]

我尝试添加"no-api":true ,我尝试设置 dev-master ,但失败.为了对其进行测试,我在BitBucket上创建了一个存储库,并且安装它没有问题.

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.

我的错误是:

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 (git@gitlab.myname/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

推荐答案

几天前,我们遇到了同样的问题.问题在于,GitLab公共Api不会公开作曲者所需的存储库的默认分支名称.到目前为止,我们发现的唯一解决方案是:

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:

  1. 转到您的GitLab帐户并创建具有读取权限的api令牌
  2. 打开您的composer.json并添加以下内容:

  1. Go to your GitLab account and create an api token with read access
  2. Open you composer.json and add this:

"config": {
    "gitlab-token": {
        "gitlab.com": "YOUR_TOKEN"
    }
},

  • 运行作曲家安装

  • Run composer install

    P.S.请谨慎使用此解决方案,因为该令牌将存储在项目存储库中并与您的团队共享.

    P.S. Use this solution with care since that token will be stored in the project repository and shared with your team.

    这篇关于GitLab:Composer使用ssh密钥安装私有存储库(仍然下载失败,下载失败)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆