Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
cmd/go: confusing "unknown revision" message when accessing private repo #42751
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:
And then to run "make vendor", a target which does:
This would fetch whatever revision "master" was pointing at and update go.mod accordingly:
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
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 github.com/meterup/otherproject: 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.
While this doesn't solve the problem of confusing errors, I do have a few suggestions for your workflow:
You can setup git and ssh configs so they will automatically use the right profiles:
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.