登录
首页 >  Golang >  Go问答

Windows 11 上的 gitlab 权限问题导致 go mod tidy 运行失败

来源:stackoverflow

时间:2024-02-07 14:18:24 365浏览 收藏

本篇文章主要是结合我之前面试的各种经历和实战开发中遇到的问题解决经验整理的,希望这篇《Windows 11 上的 gitlab 权限问题导致 go mod tidy 运行失败》对你有很大帮助!欢迎收藏,分享给更多的需要的朋友学习~

问题内容

我能够很好地执行克隆、推送和其他 git 命令(必须存储在 windows 中的凭据管理器中)。但是当我执行 go mod tidy 时出现问题

下面是我在 windows 机器上执行 go mod tidy 时遇到的错误。看起来无法访问私有存储库。

gitlab.xxxxx.de/cxxxxs-v2/arc-lib/cxxxxs-go-lib/pkg/clients:
gitlab.xxxx.de/cxxxxs-v2/arc-lib/[email protected]: verifying
module: gitlab.xxxx.de/cxxxxs-v2/arc-lib/[email protected]:
reading
https://sum.golang.org/lookup/gitlab.xxxxx.de/cxxxxs-v2/arc-lib/[email protected]:
404 not found
    server response:
    not found: gitlab.xxxxx.de/cxxxxs-v2/arc-lib/[email protected]: invalid
version: git ls-remote -q origin in
/tmp/gopath/pkg/mod/cache/vcs/387e08be1426cc3d2399d471d4c4b55445c31d6ca639398a03889c4c3282d1d5:
exit status 128:
            fatal: could not read username for 'https://gitlab.xxxxx.de': terminal prompts disabled
    confirm the import path was entered correctly.
    if this is a private repository, see https://golang.org/doc/faq#git_https for additional information.

我已经创建了 home 环境变量,指向与 userprofile 相同的文件夹。

还创建了 _netrc 文件,其中包含计算机、用户名和密码。 与 web gitlab 登录中使用的用户名和密码相同,工作正常。

_netrc内容:

machine gitlab.aaaaaa.de
login ranjit.kumar
password *****

我无法弄清楚如何调试它以找到根本原因并因此找到解决方案。请指导我。


正确答案


阅读https://sum.golang.org/lookup/gitlab.xxxxx.de/cidaas-v2/arc-lib/[电子邮件受保护]:404 未找到

它尝试在 go sumdb 中查找您的私有模块。由于您的模块是私有的,因此它不存在。

您应该将私有模块的 glob 模式添加到 goprivate。这样做:

go env -w GOPRIVATE=gitlab.xxxxx.de

goprivate 充当 gonoproxygonosumdb 的默认值。它告诉 go 工具直接从私有存储库(gonoproxy)下载模块,而不是使用公共校验和数据库(gonosumdb)检查模块。

有关更多信息,请参阅私有模块

顺便说一句,如果您可以在没有 _netrc 的情况下提取或推送到存储库,则无需设置 _netrc 。设置 home 环境变量似乎也无关紧要。

今天带大家了解了的相关知识,希望对你有所帮助;关于Golang的技术知识我们会一点点深入介绍,欢迎大家关注golang学习网公众号,一起学习编程~

声明:本文转载于:stackoverflow 如有侵犯,请联系study_golang@163.com删除
相关阅读
更多>
最新阅读
更多>
课程推荐
更多>