由于验证错误,无法安装替换的Go软件包。

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

Cannot install a replaced go package due to verification error

问题

我正在尝试通过将私有仓库替换为tensorflow来安装tensorflow。由于它无法读取我私有gitlab的用户详细信息,因此无法安装。我已经在git配置中将https替换为ssh,并尝试启用命令提示符。看起来验证步骤失败了。

以下是我的go.mod文件:

go 1.18

replace (
    github.com/tensorflow/tensorflow => git.myrepos.com/team/tensorflow v1.0.0
)

require (
    github.com/tensorflow/tensorflow v0.0.0-00010101000000-000000000000
)

这是我的.gitconfig文件:

➜  tensorflow cat /Users/myuser/.gitconfig
# This is Git's per-user configuration file.
[user]
# Please adapt and uncomment the following lines:
    name = myuser
    email = myuser@myrepos2.com
insteadOf = https://git.myrepos.com/ [core] editor = nano
insteadOf = https://gitlab.com/ insteadOf = https://gitlab.com/

我还尝试了以下方法:

export GIT_TERMINAL_PROMPT=1
env GIT_TERMINAL_PROMPT=1 go get github.com/tensorflow/tensorflow/tensorflow/go

更新:

GIT_TERMINAL_PROMPT=1 GIT_TRACE=1 GIT_CURL_VERBOSE=1 go get github.com/tensorflow/tensorflow/tensorflow/go

go: github.com/tensorflow/tensorflow@v0.0.0-00010101000000-000000000000 (replaced by git.myrepo.com/team/tensorflow@v1.0.0): verifying go.mod: git.myrepo.com/team/tensorflow@v1.0.0/go.mod: reading https://sum.golang.org/lookup/git.myrepo.com/team/tensorflow@v1.0.0: 410 Gone
    server response:
    not found: git.myrepo.com/team/tensorflow@v1.0.0: invalid version: git ls-remote -q origin in /tmp/gopath/pkg/mod/cache/vcs/2658c7dea94643a56da034a91ab984d322bf101412d6039a91e73001beedffd2: exit status 128:
        fatal: could not read Username for 'https://git.myrepo.com': 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.

为了提供更多上下文,看起来输出是https://sum.golang.org/lookup/git.myrepo.com/tream/tensorflow@v1.0.0的输出:

请注意,出于隐私目的,我替换了真实的URL。

not found: git.myrepo.com/team/tensorflow@v1.0.0: invalid version: git ls-remote -q origin in /tmp/gopath/pkg/mod/cache/vcs/2658c7dea94643a56da034a91ab984d322bf101412d6039a91e73001beedffd2: exit status 128:
    fatal: could not read Username for 'https://git.myrepo.com': 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'm truing to install tensorflow by replacing it with a private repo. It wont install since it says it cant read user details for my private gitlab. I've replaced https by ssh in git config and also tried enabling command prompt. Looks like the verification step fails.

go mod download github.com/tensorflow/tensorflow
go: git.myrepos.com/team/tensorflow@v1.0.0: verifying go.mod: git.myrepos.com/team/tensorflow@v1.0.0/go.mod: reading https://sum.golang.org/lookup/git.myrepos.com/team/tensorflow@v1.0.0: 410 Gone
	server response:
	not found: git.myrepos.com/team/tensorflow@v1.0.0: invalid version: git ls-remote -q origin in /tmp/gopath/pkg/mod/cache/vcs/2658c7dea94643a56da034a91ab984d322bf101412d6039a91e73001beedffd2: exit status 128:
		fatal: could not read Username for 'https://git.myrepos.com': 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.

And my go.mod

go 1.18


replace (
	github.com/tensorflow/tensorflow => git.myrepos.com/team/tensorflow v1.0.0
)

require (
	github.com/tensorflow/tensorflow v0.0.0-00010101000000-000000000000
)

Here's my .gitconfig

➜  tensorflow cat /Users/myuser/.gitconfig
# This is Git's per-user configuration file.
[user]
# Please adapt and uncomment the following lines:
	name = myuser
	email = myuser@myrepos2.com
insteadOf = https://git.myrepos.com/ [core] editor = nano
insteadOf = https://gitlab.com/ insteadOf = https://gitlab.com/

I've also tried this:

export GIT_TERMINAL_PROMPT=1
env GIT_TERMINAL_PROMPT=1 go get github.com/tensorflow/tensorflow/tensorflow/go

Update:

GIT_TERMINAL_PROMPT=1 GIT_TRACE=1 GIT_CURL_VERBOSE=1 go get github.com/tensorflow/tensorflow/tensorflow/go 

go: github.com/tensorflow/tensorflow@v0.0.0-00010101000000-000000000000 (replaced by git.myrepo.com/team/tensorflow@v1.0.0): verifying go.mod: git.myrepo.com/team/tensorflow@v1.0.0/go.mod: reading https://sum.golang.org/lookup/git.myrepo.com/team/tensorflow@v1.0.0: 410 Gone
	server response:
	not found: git.myrepo.com/team/tensorflow@v1.0.0: invalid version: git ls-remote -q origin in /tmp/gopath/pkg/mod/cache/vcs/2658c7dea94643a56da034a91ab984d322bf101412d6039a91e73001beedffd2: exit status 128:
		fatal: could not read Username for 'https://git.myrepo.com': 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.

To add more context. Looks like the output is the output of https://sum.golang.org/lookup/git.myrepo.com/tream/tensorflow@v1.0.0:

Notice that I replaced the true URL for privacy purposes

not found: git.myrepo.com/team/tensorflow@v1.0.0: invalid version: git ls-remote -q origin in /tmp/gopath/pkg/mod/cache/vcs/2658c7dea94643a56da034a91ab984d322bf101412d6039a91e73001beedffd2: exit status 128:
	fatal: could not read Username for 'https://git.myrepo.com': 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 dont understand why it tries to verify my package or how to avoid that. Clearly only I have access to it

答案1

得分: 2

通过导出这个环境变量来解决:

GOPRIVATE=git.myrepo.com/team

从go doc https://pkg.go.dev/cmd/go#hdr-Configuration_for_downloading_non_public_code 中可以找到更多关于下载非公共代码的配置信息。

英文:

Solved by exporting this env var:

GOPRIVATE=git.myrepo.com/team

From go doc https://pkg.go.dev/cmd/go#hdr-Configuration_for_downloading_non_public_code

答案2

得分: 0

通过以下方式解决:

  • 验证 GOPRIVATE 是否正确定义:go env -w GOPRIVATE="<private_repo>/*"
  • 验证私有仓库是否在 .gitconfig 中正确定义
  • 删除有问题的缓存:rm -rf /tmp/gopath/pkg/mod/cache/vcs/2658c7dea94643a56da034a91ab984d322bf101412d6039a91e73001beedffd2
英文:

Solved it by:

  • Verify GOPRIVATE is well defined: go env -w GOPRIVATE=&quot;&lt;private_repo&gt;/*&quot;
  • Verify private repo is well defined at .gitconfig
  • remove the problematic cache: rm -rf /tmp/gopath/pkg/mod/cache/vcs/2658c7dea94643a56da034a91ab984d322bf101412d6039a91e73001beedffd2

huangapple
  • 本文由 发表于 2022年5月12日 21:43:02
  • 转载请务必保留本文链接:https://go.coder-hub.com/72216723.html
匿名

发表评论

匿名网友

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

确定