英文:
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来获取任何依赖项,就像我在这里所做的。
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:
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论