etcd: go get error for 3.4.0

go get go.etcd.io/etcd@v3.4.0
go: finding golang.org/x/net master
go: finding go.etcd.io/etcd v3.4.0
go: finding go.etcd.io/etcd v3.4.0
go get go.etcd.io/etcd@v3.4.0: go.etcd.io/etcd@v3.4.0: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v3

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 37
  • Comments: 48 (5 by maintainers)

Commits related to this issue

Most upvoted comments

Can you either please remove the go.mod from the project or fix it?

If you are exposing a go module, you should be following its rules. That means that your go.mod needs to expose the actual major version as the module – go.etcd.io/etcd/v3.

The behavior right now is that go modules, despite you having a go.mod, decides that your repo is incompatible and gets the latest tag made, regardless of which branch that tag actually points to. And the only way to get released tags with go modules is to get the commit ID and explicitly use that.

If you changed that and Travis broke, please fix Travis. It is unsurprising there would need to be changes since it means that you will have to update import paths. But that is trivial to do, it will make go modules actually work correctly, and it has to be done at some point anyways.

When will this problem be solved? It wasted me at least an hour to deal with dependency issues! image

Let me look into this.

I have spent the last 9 months trying to train/empower others to take ownership of infrastructure I have owned throughout the kube ecosystem. And unfortunately part of that has meant I haven’t spent much time focused on any one project.

But, this issue seems to still be falling through the cracks for months. So, I will try to figure it out.

This will be fixed in etcd v3.5.0 via #11823

Hey guys, is there at least a tentative ETA on when this is going to be fixed?

@fredczj The maintainers aren’t paying attention and don’t care anyways.

They could solve this issue in two seconds by removing the go.mod entirely but instead they leave an invalid file and cause problems for every single downstream project, and it’s been that way for six months.

Alternately they could fix this by fixing the import path in go.mod, creating a tag with the new go.mod so that it’s actually fetchable (which #11221 failed to do), and fix their CI. More work, but better rewards.

We’re all just screaming into the void at this point, though.

Here is a temporary workaround (change the v3.4.3 to the tag/release you want)

git clone --branch v3.4.3 https://github.com/etcd-io/etcd.git
cd etcd
echo -n v0.0.0-
TZ=UTC git --no-pager show \
  --quiet \
  --abbrev=12 \
  --date='format-local:%Y%m%d%H%M%S' \
  --format="%cd-%h"

Take note of the v0.0.0-… (v0.0.0-20191023171146-3cf2f69b5738 for tag v3.4.3 for example) and change your go.mod etcd import like this

go.etcd.io/etcd v0.0.0-20191023171146-3cf2f69b5738

It should now work. thanks to https://stackoverflow.com/a/59440771 for the tip on how to compute what’s after v0.0.0-

  • @latest is v3.3.15+incompatible according to go get for golang 1.13.1
  • explicit @v3.4.1 doesn’t work due to the module path in that version being go.etcd.io/etcd instead of go.etcd.io/etcd/v3 (I think)
  • Using go get -u go.etcd.io/etcd/clientv3@a14579f (the sha1 of the v3.4.1 release) results in usage of v0.5.0-alpha.5.0.20190917205325-a14579fbfb1a with has the right commit at the end, but a wacky old version (I believe it gets the right code)
  • Using go get -u go.etcd.io/etcd/clientv3@v0.0.0-20190917205325-a14579fbfb1a gets the right commit, but with a less wrong tag than above

Full reproduction:

graham@graham:~/tmp/etcd-mod$ go version
go version go1.13.1 linux/amd64
graham@graham:~/tmp/etcd-mod$ cat main.go 
package main

import "go.etcd.io/etcd/clientv3"

func main() { clientv3.New(clientv3.Config{}) }
graham@graham:~/tmp/etcd-mod$ go mod init etcd-mod
go: creating new go.mod: module etcd-mod
graham@graham:~/tmp/etcd-mod$ go mod tidy
go: finding golang.org/x/crypto latest
go: finding github.com/coreos/pkg latest
go: finding github.com/coreos/go-systemd latest
go: finding github.com/xiang90/probing latest
go: finding golang.org/x/time latest
go: finding github.com/tmc/grpc-websocket-proxy latest
go: finding github.com/golang/groupcache latest
graham@graham:~/tmp/etcd-mod$ cat go.mod 
module etcd-mod

go 1.13

require (
	github.com/coreos/bbolt v1.3.3 // indirect
	github.com/coreos/etcd v3.3.15+incompatible // indirect
	github.com/coreos/go-semver v0.3.0 // indirect
	github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect
	github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
	github.com/dgrijalva/jwt-go v3.2.0+incompatible // indirect
	github.com/golang/groupcache v0.0.0-20191002201903-404acd9df4cc // indirect
	github.com/google/btree v1.0.0 // indirect
	github.com/google/uuid v1.1.1 // indirect
	github.com/gorilla/websocket v1.4.1 // indirect
	github.com/grpc-ecosystem/go-grpc-middleware v1.1.0 // indirect
	github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
	github.com/grpc-ecosystem/grpc-gateway v1.11.3 // indirect
	github.com/jonboulle/clockwork v0.1.0 // indirect
	github.com/prometheus/client_golang v1.1.0 // indirect
	github.com/soheilhy/cmux v0.1.4 // indirect
	github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
	github.com/xiang90/probing v0.0.0-20190116061207-43a291ad63a2 // indirect
	go.etcd.io/bbolt v1.3.3 // indirect
	go.etcd.io/etcd v3.3.15+incompatible
	go.uber.org/multierr v1.2.0 // indirect
	golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc // indirect
	golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0 // indirect
	google.golang.org/grpc v1.24.0 // indirect
	sigs.k8s.io/yaml v1.1.0 // indirect
)
graham@graham:~/tmp/etcd-mod$ go get -u go.etcd.io/etcd/clientv3@v3.4.1
go: finding go.etcd.io v3.4.1
go: finding go.etcd.io/etcd/clientv3 v3.4.1
go: finding go.etcd.io/etcd v3.4.1
go: finding go.etcd.io/etcd v3.4.1
go: finding go.etcd.io/etcd/clientv3 v3.4.1
go get go.etcd.io/etcd/clientv3@v3.4.1: go.etcd.io/etcd@v3.4.1: invalid version: module contains a go.mod file, so major version must be compatible: should be v0 or v1, not v3
graham@graham:~/tmp/etcd-mod$ go get -u go.etcd.io/etcd/clientv3@a14579f
go: finding go.etcd.io a14579f
go: finding go.etcd.io/etcd a14579f
go: finding go.etcd.io/etcd/clientv3 a14579f
go: finding github.com/coreos/go-systemd latest
go: finding golang.org/x/sys latest
go: finding github.com/coreos/pkg latest
go: finding golang.org/x/net latest
go: finding google.golang.org/genproto latest
graham@graham:~/tmp/etcd-mod$ cat go.mod 
module etcd-mod

go 1.13

require (
	github.com/coreos/bbolt v1.3.3 // indirect
	github.com/coreos/etcd v3.3.15+incompatible // indirect
	github.com/coreos/go-semver v0.3.0 // indirect
	github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f // indirect
	github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f // indirect
	github.com/gogo/protobuf v1.3.0 // indirect
	github.com/golang/groupcache v0.0.0-20191002201903-404acd9df4cc // indirect
	github.com/google/uuid v1.1.1 // indirect
	github.com/gorilla/websocket v1.4.1 // indirect
	github.com/grpc-ecosystem/go-grpc-middleware v1.1.0 // indirect
	github.com/grpc-ecosystem/grpc-gateway v1.11.3 // indirect
	github.com/prometheus/client_golang v1.1.0 // indirect
	github.com/tmc/grpc-websocket-proxy v0.0.0-20190109142713-0ad062ec5ee5 // indirect
	go.etcd.io/etcd v0.5.0-alpha.5.0.20190917205325-a14579fbfb1a
	go.uber.org/multierr v1.2.0 // indirect
	golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc // indirect
	golang.org/x/net v0.0.0-20191003171128-d98b1b443823 // indirect
	golang.org/x/sys v0.0.0-20191003212358-c178f38b412c // indirect
	golang.org/x/text v0.3.2 // indirect
	golang.org/x/time v0.0.0-20190921001708-c4c64cad1fd0 // indirect
	google.golang.org/genproto v0.0.0-20191002211648-c459b9ce5143 // indirect
	google.golang.org/grpc v1.24.0 // indirect
)

Well, at least now we have a corona virus to blame for the delay.

it works when add this to go.mod file replace go.etcd.io/etcd => go.etcd.io/etcd v0.0.0-20200520232829-54ba9589114f

and wait for v3.5 …

Please delete go.mod, it’s invalid and more harmful for imports than just omitting it.

EDIT

Unfortunately removal of go.mod is not a bulletproof solution either. Quite a few third party packages pull in v3.4.* using a workaround (https://github.com/etcd-io/etcd/pull/11477, great work by obsider). While most imports seem to refer to a specific commit, there is still a risk of breaking one of those workaround imports. One could argue that breaking a workaround is a lesser evil than fixing a bad import bug.

Still, afaik there are only two correct approaches:

  • Set correct module path in go.mod and tag a new release: module go.etcd.io/etcd/v3. Ideally test this using a fake GOPROXY first.
  • Remove go mod entirely, and rely on legacy/fallback import.

asdsadad

may be for etcd this is beginning of the end

@philips ?

image

(⊙o⊙)…

@moggle-mog: have you tried with go.etcd.io/etcd?

Just curious. I worked around it by using go get -u go.etcd.io/etcd/clientv3@v0.0.0-20190917205325-a14579fbfb1a for now.