Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

go build can't find a revision

Tags:

github

module

go

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.

like image 971
Ravenwater Avatar asked Apr 03 '19 19:04

Ravenwater


People also ask

What does go mod tidy do?

mod requirements match the source code of the module, Go Modules provides the go mod tidy command. It will add any missing dependency being used by the source code to the list of requirements in the go. mod file, and can be useful to get the requirements list when we are trying to convert a project to Go Modules.

What is GO111MODULE?

GO111MODULE is an environment variable that can be set when using go for changing how Go imports packages. One of the first pain-points is that depending on the Go version, its semantics change.

What is Goprivate?

GOPRIVATE: lists packages that are considered private. The go command does not use the GOPRIVATE or checksum database when downloading and validating these packages. Read more about GOPRIVATE in Module configuration for non-public modules at golang.org.

What Go mod vendor do?

The go mod vendor command constructs a directory named vendor in the main module's root directory that contains copies of all packages needed to support builds and tests of packages in the main module. Packages that are only imported by tests of packages outside the main module are not included.


2 Answers

Possible solutions for golang unknown revision if you are using private repository:

  1. git config --global url."ssh://git@yourserver".insteadOf "https://yourserver"

  2. Check your git repository permissions

like image 193
igonejack Avatar answered Oct 17 '22 06:10

igonejack


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>
like image 44
dixoen Avatar answered Oct 17 '22 08:10

dixoen