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/mod: replace package with tag already containing a '+' does not work with '+incompatible' #32106

Closed
sylr opened this issue May 17, 2019 · 3 comments

Comments

@sylr
Copy link

sylr commented May 17, 2019

What version of Go are you using (go version)?

$ go version
go version go1.12.5 linux/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

Trying to compile https://github.com/improbable-eng/thanos with a dependency replacement, i.e.:

module github.com/improbable-eng/thanos

require (
        cloud.google.com/go v0.34.0
        github.com/Azure/azure-storage-blob-go v0.0.0-20181022225951-5152f14ace1c
        github.com/NYTimes/gziphandler v1.1.1
        github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da
        github.com/fatih/structtag v1.0.0
        github.com/fortytw2/leaktest v1.3.0
        github.com/fsnotify/fsnotify v1.4.7
        github.com/go-kit/kit v0.8.0
        github.com/gogo/protobuf v1.2.1
        github.com/golang/snappy v0.0.1
        github.com/google/martian v2.1.0+incompatible // indirect
        github.com/googleapis/gax-go v2.0.2+incompatible // indirect
        github.com/gophercloud/gophercloud v0.0.0-20190301152420-fca40860790e
        github.com/grpc-ecosystem/go-grpc-middleware v1.0.0
        github.com/grpc-ecosystem/go-grpc-prometheus v0.0.0-20181025070259-68e3a13e4117
        github.com/hashicorp/go-sockaddr v1.0.2
        github.com/hashicorp/go-version v1.2.0
        github.com/hashicorp/golang-lru v0.5.1
        github.com/hashicorp/memberlist v0.1.3
        github.com/lovoo/gcloud-opentracing v0.3.0
        github.com/miekg/dns v1.1.8
        github.com/minio/minio-go v0.0.0-20190131015406-c8a261de75c1
        github.com/mozillazg/go-cos v0.12.0
        github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223
        github.com/oklog/run v1.0.0
        github.com/oklog/ulid v1.3.1
        github.com/olekukonko/tablewriter v0.0.1
        github.com/opentracing-contrib/go-stdlib v0.0.0-20170113013457-1de4cc2120e7
        github.com/opentracing/basictracer-go v1.0.0
        github.com/opentracing/opentracing-go v1.0.2
        github.com/pkg/errors v0.8.1
        github.com/prometheus/client_golang v0.9.3-0.20190127221311-3c4408c8b829
        github.com/prometheus/common v0.4.0
        github.com/prometheus/prometheus v2.9.2+incompatible
        github.com/prometheus/tsdb v0.7.2-0.20190507100016-6ac81cc7a9c5
        golang.org/x/net v0.0.0-20190311183353-d8887717615a
        golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421
        golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6
        golang.org/x/sys v0.0.0-20190322080309-f49334f85ddc // indirect
        golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2
        google.golang.org/api v0.3.2
        google.golang.org/grpc v1.19.1
        gopkg.in/alecthomas/kingpin.v2 v2.2.6
        gopkg.in/fsnotify/fsnotify.v1 v1.4.7 // indirect
        gopkg.in/yaml.v2 v2.2.2
)

replace github.com/prometheus/prometheus => github.com/sylr/prometheus v2.9.2+sylr.2+incompatible

What did you expect to see?

What did you see instead?

sylvain@ubuntu-1604-dev:~/gopath/src/github.com/improbable-eng/thanos[prometheus-2.9.2]$ make build
go: finding github.com/sylr/prometheus v2.9.2+sylr.2+incompatible
go: errors parsing go.mod:
/home/sylvain/gopath/src/github.com/improbable-eng/thanos/go.mod:51: invalid module version github.com/sylr/prometheus: unknown revision v2.9.2+sylr.2+incompatible
Makefile:213: recipe for target 'go-mod-tidy' failed
make: *** [go-mod-tidy] Error 1
@bcmills
Copy link
Contributor

bcmills commented May 17, 2019

We add the +incompatible suffix after resolving the tag to what we call a “canonical” semantic version string (that is, one without metadata). v2.9.2+sylr.2 is not canonical, so the go command doesn't know what to do with that suffix.

Due to the fix for #31713, v2.9.2+sylr.2 (without the +incompatible suffix) should work in Go 1.13.

@bcmills
Copy link
Contributor

bcmills commented May 17, 2019

There is kind of a funny interaction with #27171 and #29262 here, though: we should resolve the tag to a pseudo-version starting with v2.9.2- and ending with +incompatible, but today we are resolving it to a pseudo-version with a v0.0.0- prefix.

$ go list -f '{{.Version}}' -m github.com/sylr/prometheus@v2.9.2+sylr.2
go: finding github.com/sylr/prometheus v2.9.2+sylr.2
v0.0.0-20190510132036-085fc219838d

@bcmills
Copy link
Contributor

bcmills commented May 17, 2019

I've retitled #29262 to include this example. I think that makes this a duplicate of #31713 (which is fixed) and #29262 (which is not). Thanks for the report — this is an interesting example to consider.

@bcmills bcmills closed this as completed May 17, 2019
@golang golang locked and limited conversation to collaborators May 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants