go build can't find a revision
Solution 1
Problem is related to cmd/go not being aware of git identities and assuming there is only one articulated in the .gitconfig file.
Work-around: have a set of git identities ready to replace global .gitconfig when you need to work with that git identity and are dealing with cmd/go tools that update the module file.
Solution 2
Possible solutions for golang unknown revision if you are using private repository:
git config --global url."ssh://git@yourserver".insteadOf "https://yourserver"
Check your git repository permissions
Solution 3
I had the same problem, please, visit the link .
Make sure you have set GO111MODULES
go env -w GO111MODULE=on
Make sure your git configuration is appropriate for private repositories
git config --global url."ssh://[email protected]:acme-corporation".insteadOf "https://github.com/acme-corporation"
Make sure to create a personal access token if using 2FA
git config --global url."https://:[email protected]:acme-corporation".insteadOf "https://github.com/acme-corporation"
in my case after setting:
- ~/.gitconfig
- ~/.bashrc
I had to do the same with the ~ / .netrc file:
machine gitlab.url.com
login <gitlab username>
password <GITLAB_TOKEN>
Solution 4
In case getting
"Error": "unknown revision ..."
or
"Error": "invalid version ..."
Make sure that you did not specify hash of PR (pull request). Even a merged PR might be wrong.
Look for the commit hash in the github repo
under /commits
, but not under /pulls
.
See more info here: golang/go#31191 explicitly filters out these kind of commits.
Solution 5
Just in case, did you add "github.ibm.com/kms"
to your environment variable GOPRIVATE
on computer B? I've had this error occur to me due to exactly this reason.
Ravenwater
Updated on August 23, 2022Comments
-
Ravenwater over 1 year
I developed a repo on computer A and created a go.mod/go.sum that I checked in.
I pull that repo with the go.mod/go.sum files on computer B, but when I try to build the program, the module constraints can't be satisfied.
$ go build go: finding github.ibm.com/kms/key-protect-client v0.1.5 go: finding golang.org/x/tools v0.0.0-20180221164845-07fd8470d635 go: github.ibm.com/kms/[email protected]: unknown revision v0.1.5 go: error loading module requirements
The repo that is failing is a private repo, and for some reason it doesn't get downloaded to the module cache. On another computer, the dependencies are downloaded and the build succeeds. I am building another private repo in that same domain, so I know that my github credentials give me access to these repos. But for some reason, the go module system can't get to the dependent repo.
I cannot find more information how to debug this.