【发布时间】:2020-08-20 08:33:18
【问题描述】:
我正在 Windows 10 上试用 WSL 2,到目前为止一切顺利,但我已经努力了 2 周来完成这项工作,因为出于某种原因 go get 不使用或无法使用让 Git 凭据管理器提示输入我的凭据。
我按照这个博客用 GCM https://www.edwardthomson.com/blog/git_credential_manager_with_windows_subsystem_for_linux.html 设置 WSL2
它非常适合大多数日常任务,例如克隆、读取和写入。但是在使用go get 时出现此错误。
go get <remote github repo>@<latest commit id>
go: <remote github repo> 681dceefc81203e094872401c184d038090d6049 => v0.0.17-0.20200501212733-681dceefc812
go get: <remote github repo>@v0.0.17-0.20200501212733-681dceefc812/go.mod: verifying module: <remote github repo>@v0.0.17-0.20200501212733-681dceefc812/go.mod: reading https://sum.golang.org/lookup/<remote github repo>@v0.0.17-0.20200501212733-681dceefc812: 410 Gone
server response:
not found: <remote github repo>@v0.0.17-0.20200501212733-681dceefc812: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /tmp/gopath/pkg/mod/cache/vcs/232ff028cb2fdebd254e30bfc612843483f0fe3fbeb18d5fc8fb4b20f21c9021: exit status 128:
fatal: could not read Username for 'https://github.com': terminal prompts disabled
已经尝试过 ssh-keys 和这里提出的解决方案go get results in 'terminal prompts disabled' error for github private repo
但是错误仍然存在,当启用 env GIT_TERMINAL_PROMPT=1 时没有任何反应,我猜这是因为 WSL 2 没有这样做的权限。无论如何,我也尝试了这个工具https://github.com/microsoft/Git-Credential-Manager-for-Mac-and-Linux,并通过为普通凭据存储设置一个变量,它会在终端中提示输入凭据。但我使用的是 2FA,因为它是组织要求的,并且提示仅要求输入用户名和密码,因此身份验证失败。
所以我必须联系使用 Mac 的伙伴。他能够go get 依赖影响go.mod,提交并推送更改,以便我可以拉取它并从那里继续。但当然这并不理想,他也没有任何问题,他使用 osxkeychain 来管理他的 git 凭据。
有人遇到过这个问题吗?或知道如何解决?非常感谢您。
【问题讨论】:
-
> 但是我使用的是 2FA,因为它是组织要求的,并且提示只要求输入用户名和密码,因此身份验证失败。:您应该能够输入您的用户名和 PAT(个人访问令牌)作为密码。 (help.github.com/en/github/authenticating-to-github/…)
-
非常感谢!当我这样做时,我能够成功进行身份验证,但随后服务器响应显示了相同的错误。我开始认为这与用户身份验证无关,而是权限问题。
标签: go github wsl-2 git-credential-manager go-get