Composer:Failed to execute git clone –mirror …Permission denied (publickey). fatal: Could not

  • Post author:
  • Post category:其他


composer获取依赖库时,若composer.json中存在非开源的gitlab项目或组件,可能出现以下错误:
Failed to execute git clone --mirror "git@gitlab.com:XXXXXX" 
"C:/Users/Administrator/AppData/Local/Composer/vcs/git-gitlab.comXXXXXXXX.git/"
Cloning into bare repository 'C:/Users/Administrator/AppData/Local/Composer/vcs/git-gitlab.comXXXXXX.git'...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

翻译:

未能执行git clone --mirror "git@gitlab.com:blue-com/XXXXXX.git"C:/Users/Administrator/AppData/Local/Composer/vcs/git-gitlab.comXXXXXX.git/"
克隆到空的仓库的'C:/Users/Administrator/AppData/Local/Composer/vcs/git-gitlab.com-XXXX.git'……
没有权限(publickey)。
致命:无法读取远程存储库。
请确保你有正确的访问权限和存储库的存在。

解决办法:

  1. 配置git环境变量:例如:”C:\Program Files\Git\cmd“加入到环境变量,若cmd运行git成功,则配置成功。
  2. 将C:\Users\Administrator.ssh\id_rsa.pub中的所有内用复制下来,加入到gitlab个人中心(

    https://gitlab.com/profile

    )左侧的SSH Key中,并保存。
  3. 确定gitlab上有获取该远程仓库的权限。

若composer获取依赖库时提示输入Token,则需要在github中注册账号,在个人设置中创建token,并将该token填入即可。



版权声明:本文为qq_16885135原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。