Git与Go Build和其他Go命令的错误

huangapple go评论92阅读模式
英文:

Git Error with Go Build and Other Go Commands

问题

尝试在Go中构建时,我遇到了以下Git错误:

Permission denied (publickey,gssapi-keyex,gssapi-with-mic).
fatal: Could not read from remote repository.

这是什么原因造成的?

我能够使用HTTP和SSH成功克隆相同的存储库,并且GitLab UI确认我具有适当的权限。

我正在运行MacOS Monterey。
非常感谢您的帮助。

英文:

When trying to build in Go, I get the following Git error:

Permission denied (publickey,gssapi-keyex,gssapi-with-mic). 
fatal: Could not read from remote repository.

What is the cause for this?

I am able to clone the same repository successfully using both HTTP and SSH and have the appropriate permissions assigned to it as confirmed by the GitLab UI.

I'm running MacOS Monterey.
Any help would be greatly appreciated.

答案1

得分: 4

请检查您正在编译的Go项目中的go.mod文件。

它可能引用了一些可能是私有的模块,您可能没有克隆的权限。
或者您可以强制使用HTTPS而不是SSH来获取任何依赖项,就像我在这里所做的

OP Foobar评论中确认:

git config --global url."gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.acme.com/".insteadOf git@gitlab.acme.com:
英文:

Check your go.mod in the Go project you are compiling.

It might refer to modules who might be private, and that you might not have the right to clone.
Or you can force using HTTPS instead of SSH for any dependencies, as I did here.

The OP Foobar confirms in the comments:

git config --global url."gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.acme.com/".insteadOf git@gitlab.acme.com:

huangapple
  • 本文由 发表于 2022年10月13日 14:13:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/74051189.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定