Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: confusing "unknown revision" message when accessing private repo #42751

kevinburkemeter opened this issue Nov 20, 2020 · 2 comments


Copy link

@kevinburkemeter kevinburkemeter commented Nov 20, 2020

I maintain a Go project that vendors dependencies. This project has dependencies on other projects in go.mod. Generally, the other projects update frequently enough that we don't release a new version every time we need to update the dependency.

The easiest way to say "get the latest version of the code" has been to edit the go.mod file to read:



require ( master

And then to run "make vendor", a target which does:

GO111MODULE=on GOFLAGS="-mod=vendor" go mod vendor && GO111MODULE=on GOFLAGS="-mod=vendor" go mod tidy

This would fetch whatever revision "master" was pointing at and update go.mod accordingly: v0.0.0-20201031004227-07502007abc0

However I have multiple Github SSH profiles set up on my computer. If I forget and have my personal SSH profile set up and try to run make vendor, Go presents the very confusing error message:

/Users/kevin/src/ require version "master" invalid: unknown revision master

It's not very obvious from this error message that the problem is my configured Git credentials can't access the repo in question. My first thought was Go somehow deprecated the VCS pseudo-version parsing in go.mod. I

understand Github does not disclose the existence of the repo if your credentials are not configured correctly (ie. returns 404 instead of 403) but maybe we could give a better suggestion to the user where the problem is ("could not retrieve repo at HTTP status 404" or something). You could make an additional HTTP request with a short timeout to attempt to determine if the problem is with the specific revision or with the repo as a whole.

@kevinburkemeter kevinburkemeter changed the title confusing "unknown revision" message when accessing private repo cmd/go: confusing "unknown revision" message when accessing private repo Nov 20, 2020
Copy link

@seankhliao seankhliao commented Nov 20, 2020

While this doesn't solve the problem of confusing errors, I do have a few suggestions for your workflow:

  • go get your@master deps@master
  • The explicit env settings are unnecessary
  • The tidy should be called before vendor to have a consistent state

You can setup git and ssh configs so they will automatically use the right profiles:

Host github-personal
    User git
    IdentityFile ~/.ssh/id_ed25519_personal

Host github-work
    User git
    IdentityFile ~/.ssh/id_ed25519_work
[url "git@github-work:"]
	insteadOf = ""

[url "git@github-personal:"]
    insteadOf = ""
Copy link

@kevinburkemeter kevinburkemeter commented Nov 20, 2020

I've written a ssh config parser and a tool to do it automatically, thanks. Just forgot which one I had active at the time.

The env settings are to override whatever the team has set in the environment, just pasted here to make clear what command I was running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.