英文:
gitlab privilege issue when running go mod tidy on Windows 11
问题
我能很好地执行克隆、推送和其他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/cxxxxs-go-lib@v1.10.1: 验证模块:
读取
https://sum.golang.org/lookup/gitlab.xxxxx.de/cxxxxs-v2/arc-lib/cxxxxs-go-lib@v1.10.1:
404 Not Found
服务器响应:
未找到: gitlab.xxxxx.de/cxxxxs-v2/arc-lib/cxxxxs-go-lib@v1.10.1: 无效
版本: git ls-remote -q origin in
/tmp/gopath/pkg/mod/cache/vcs/387e08be1426cc3d2399d471d4c4b55445c31d6ca639398a03889c4c3282d1d5:
退出状态 128:
致命: 无法读取用户名以供 'https://gitlab.xxxxx.de': 终端提示已禁用
确认导入路径是否输入正确。
如果这是一个私有仓库,请参阅 https://golang.org/doc/faq#git_https 获取其他信息。
我已经创建了HOME
环境变量,指向与USERPROFILE
相同的文件夹。
还创建了包含机器、用户名和密码的_netrc
文件。
在Web GitLab登录中使用相同的用户名和密码,它可以正常工作。
_netrc
文件内容:
machine gitlab.aaaaaa.de
login ranjit.kumar
password *****
我无法找出如何调试此问题以找到根本原因和解决方案。请指导我。
英文:
I am able to do clone, push and other git commands very well (must be stored in credential manager in windows). But issue appear when I execute go mod tidy
Below is the error I got when executing go mod tidy
on my windows machine. Looks like no access to private repository.
gitlab.xxxxx.de/cxxxxs-v2/arc-lib/cxxxxs-go-lib/pkg/clients:
gitlab.xxxx.de/cxxxxs-v2/arc-lib/cxxxxs-go-lib@v1.10.1: verifying
module: gitlab.xxxx.de/cxxxxs-v2/arc-lib/cxxxxs-go-lib@v1.10.1:
reading
https://sum.golang.org/lookup/gitlab.xxxxx.de/cxxxxs-v2/arc-lib/cxxxxs-go-lib@v1.10.1:
404 Not Found
server response:
not found: gitlab.xxxxx.de/cxxxxs-v2/arc-lib/cxxxxs-go-lib@v1.10.1: 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.
I have created the HOME
env variables, pointing to same folder as USERPROFILE
.
Also created _netrc
file with machine, username and password.
Same username and password used in web gitlab login, it works fine.
_netrc
content :
machine gitlab.aaaaaa.de
login ranjit.kumar
password *****
I am not able to figure out how to debug this to find rootcause and hence the solution. Please guide me on this.
答案1
得分: 1
> 读取 https://sum.golang.org/lookup/gitlab.xxxxx.de/cidaas-v2/arc-lib/cidaas-go-lib@v1.10.1: 404 Not Found
它试图在 Go SUMDB 中查找您的私有模块。由于您的模块是私有的,所以在那里找不到。
您应该将您的私有模块的通配符模式添加到 GOPRIVATE
中。可以像这样执行:
go env -w GOPRIVATE=gitlab.xxxxx.de
GOPRIVATE
作为 GONOPROXY
和 GONOSUMDB
的默认值。它告诉 go 工具直接从私有仓库下载模块(GONOPROXY
),而不使用公共校验和数据库检查模块(GONOSUMDB
)。
有关更多信息,请参阅私有模块。
顺便说一下,如果您可以在没有设置 _netrc
的情况下获取或推送到仓库,则不需要设置它。设置 HOME
环境变量似乎也不相关。
英文:
> reading https://sum.golang.org/lookup/gitlab.xxxxx.de/cidaas-v2/arc-lib/cidaas-go-lib@v1.10.1: 404 Not Found
It tries to lookup your private module in the Go SUMDB. Since your module is private, it's not there.
You should add the glob pattern of your private module to GOPRIVATE
. Do it like this:
go env -w GOPRIVATE=gitlab.xxxxx.de
GOPRIVATE
acts as a default value for GONOPROXY
and GONOSUMDB
. It tells the go tool to download the module from the private repository directly (GONOPROXY
) and not to check the module using the public checksum database (GONOSUMDB
).
See Private modules for more information.
BTW, you don't need to set _netrc
if you can fetch or push to the repository without it. And setting the HOME
environment variable seems irrelevant too.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论