go: github.com/myorg/myrepo@v0.0.4: reading github.com/myorg/myrepo/go.mod at revision v0.0.4: unknown revision v0.0.4

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

go: github.com/myorg/myrepo@v0.0.4: reading github.com/myorg/myrepo/go.mod at revision v0.0.4: unknown revision v0.0.4

问题

go: github.com/myorg/myrepo@v0.0.4: 在版本 v0.0.4 上读取 github.com/myorg/myrepo/go.mod: 未知版本 v0.0.4

当我在一个不同的私有仓库 github.com/myorg/myrepo2 中执行 go mod tidy 并尝试从我的私有仓库 github.com/myorg/myrepo 获取时,遇到了上述阻塞问题。

github.com/myorg/myrepo 主分支的 go.mod 内容如下(在项目根目录):

module github.com/myorg/myrepo

go 1.15

require (
	github.com/abadojack/whatlanggo v1.0.1
	github.com/mmcdole/gofeed v1.1.3
	github.com/stretchr/testify v1.3.0
)

该仓库实际上有一个名为 v0.0.4 的标签/发布版本。

此外,我已经尝试了以下所有方法:

也就是说,我已经尝试配置 ~/.gitconfigGOPRIVATE 和其他环境变量、~/$HOME/.netrc,甚至生成了一个 GitHub 访问令牌。值得注意的是,我在这台机器上还有一个与 GitHub 账户关联的 SSH 密钥,并且 ~/.ssh/config 的内容如下:

Host *
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_ed12345

Host github.com
  Hostname ssh.github.com
  Port 443

我还排除了这里描述的子模块问题 https://stackoverflow.com/questions/64893018/reading-github-com-username-kit-go-database-go-database-go-mod-at-revision-go-da

对于这个问题,我感到困惑,所以任何帮助将不胜感激。

英文:

go: github.com/myorg/myrepo@v0.0.4: reading github.com/myorg/myrepo/go.mod at revision v0.0.4: unknown revision v0.0.4

I'm hitting the above blocker when go mod tidy inside a different private repo call it: github.com/myorg/myrepo2 and attempting to fetch from my private repo github.com/myorg/myrepo

Contents of github.com/myorg/myrepo master branch go.mod (at the root project level)

module github.com/myorg/myrepo

go 1.15

require (
	github.com/abadojack/whatlanggo v1.0.1
	github.com/mmcdole/gofeed v1.1.3
	github.com/stretchr/testify v1.3.0
)

The repo has in fact a tag / release named v0.0.4

Additionally, I've tried everything described in the following:

That is to say, I've tried configuring ~/.gitconfig, GOPRIVATE and other env vars, ~/$HOME/.netrc,and even generating a GitHub access token. I should note that I also have an SSH key associated with Github account on this machine and ~/.ssh/config contents as below:

Host *
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_ed12345

Host github.com
  Hostname ssh.github.com
  Port 443

I also ruled out the submodule issue described here https://stackoverflow.com/questions/64893018/reading-github-com-username-kit-go-database-go-database-go-mod-at-revision-go-da

I'm at a loss on this one so any help would be appreciated.

答案1

得分: 1

如果Go通过HTTPS访问您的私有存储库,那么SSH设置将不会被使用。根据您的链接,可以尝试以下操作(在执行go clean -modcache之后):

git config --global \
  url."https://${GITHUB_TOKEN}@github.com".insteadOf \
  "https://github.com"
go mod download

如果您想使用SSH:

git config --global url."ssh://git@github.com:acme-corporation".insteadOf "https://github.com/acme-corporation"

(将acme-corporation替换为您的GitHub用户帐户,假设您的私有存储库不在组织中)
(检查ssh -Tv git@github.com是否作为您进行了身份验证)

然后设置export GIT_SSH_COMMAND='ssh -Tv':这样,您将能够准确查看SSH调用期间的情况,并确保确实使用了您的私钥。

OP j-diaz评论中确认了他们的Git配置问题:

> 我最终检查了.gitconfig文件中的每个条目,并最终删除了除用户条目之外的所有内容,这样就解决了问题。
>
> [user]
> name = First Last
> email = email@exmaple.com

英文:

If Go is accessing your private repository through HTTPS, then any SSH setting would not be used at all.
From your link, this should have helped (after a go clean -modcache):

git config --global \
  url."https://${GITHUB_TOKEN}@github.com".insteadOf \
  "https://github.com"
go mod download

If you want to use/try SSH:

git config --global url."ssh://git@github.com:acme-corporation".insteadOf "https://github.com/acme-corporation"

(replace acme-corporation by your GitHub user account, assuming your private repository is not in an organization)
(check ssh -Tv git@github.com does authenticate as you)

Then export GIT_SSH_COMMAND='ssh -Tv': that way, you will see exactly what is considered during the SSH calls, and make sure your private key is indeed used.


The OP j-diaz confirms in the comments an issue in their Git configuration:

> I ended up revising every entry in my .gitconfig file and ended up removing everything except the user entry and that made it work.
>
> [user]
> name = First Last
> email = email@exmaple.com

huangapple
  • 本文由 发表于 2021年12月7日 11:48:35
  • 转载请务必保留本文链接:https://go.coder-hub.com/70254721.html
匿名

发表评论

匿名网友

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

确定