moby: Unable to use Go SDK due to dependency collision

Expected behavior

I should not have problems when building my go module

Actual behavior and steps to reproduce

I get a never-ending rabbit hole of dependency/module/package conflicts that end with a dead-end. It starts like this:

Go module:

module github.com/path/to/module

go 1.13

require github.com/apache/pulsar-client-go v0.1.1

My code contains these imports:

	"github.com/docker/docker/container"
	"github.com/docker/docker/api/server/router/container"
	"github.com/docker/docker/api/types"
	"github.com/docker/docker/api/types/container"
	"github.com/docker/docker/client"
	"github.com/docker/go-connections/nat"
	"context"
	"fmt"
	"log"
	"os"
	"github.com/apache/pulsar-client-go/pulsar"

Then, I run: go get -v -u all

and get this:

go: finding github.com/docker/libtrust latest
go: finding github.com/tonistiigi/fifo latest
go: finding golang.org/x/time latest
go: finding github.com/Azure/go-ansiterm latest
go: my-package imports
        github.com/docker/docker/api/server/router/container imports
        github.com/Sirupsen/logrus: github.com/Sirupsen/logrus@v1.6.0: parsing go.mod:
        module declares its path as: github.com/sirupsen/logrus
                but was required as: github.com/Sirupsen/logrus

So, I replace it by adding a replace line to the go.mod file like this:

module github.com/path/to/module

go 1.13

require github.com/apache/pulsar-client-go v0.1.1

replace github.com/Sirupsen/logrus => github.com/sirupsen/logrus v1.6.0

which leads to this:

$ go get -v -u all
go: finding github.com/tonistiigi/fifo latest
go: finding github.com/docker/libtrust latest
go: finding github.com/Azure/go-ansiterm latest
go: finding golang.org/x/time latest
go: my-package imports
        github.com/docker/docker/container imports
        github.com/docker/docker/libcontainerd imports
        github.com/tonistiigi/fifo: github.com/tonistiigi/fifo@v0.0.0-20200410184934-f15a3290365b: parsing go.mod:
        module declares its path as: github.com/containerd/fifo
                but was required as: github.com/tonistiigi/fifo

So, I add another replace to go.mod, like this:

module github.com/path/to/module

go 1.13

require github.com/apache/pulsar-client-go v0.1.1

replace github.com/Sirupsen/logrus => github.com/sirupsen/logrus v1.6.0

replace github.com/tonistiigi/fifo => github.com/containerd/fifo latest

which leads to this:

$ go get -v -u all
go: finding github.com/containerd/fifo latest
go: finding github.com/docker/libtrust latest
go: finding github.com/Azure/go-ansiterm latest
go: finding golang.org/x/time latest
go: finding github.com/go-check/check latest
go: finding github.com/vishvananda/netns latest
go: finding github.com/syndtr/gocapability latest
go: finding github.com/coreos/pkg latest
go: finding github.com/niemeyer/pretty latest
go: finding github.com/samuel/go-zookeeper latest
go: finding github.com/xiang90/probing latest
go: finding github.com/tmc/grpc-websocket-proxy latest
go: finding github.com/golang/groupcache latest
go: my-package imports
        github.com/docker/docker/container imports
        github.com/docker/libnetwork imports
        github.com/docker/libnetwork/datastore imports
        github.com/docker/libkv/store/etcd imports
        github.com/coreos/etcd/client tested by
        github.com/coreos/etcd/client.test imports
        github.com/coreos/etcd/integration imports
        github.com/coreos/etcd/etcdserver imports
        github.com/coreos/etcd/mvcc/backend imports
        github.com/coreos/bbolt: github.com/coreos/bbolt@v1.3.5: parsing go.mod:
        module declares its path as: go.etcd.io/bbolt
                but was required as: github.com/coreos/bbolt

So, I add this replace line to my go.mod file:

replace github.com/coreos/bbolt => go.etcd.io/bbolt latest

which leads to this dead-end:

$ go get -v -u all
go: finding github.com/docker/libtrust latest
go: finding golang.org/x/time latest
go: finding github.com/Azure/go-ansiterm latest
go: finding github.com/vishvananda/netns latest
go: finding github.com/coreos/pkg latest
go: finding github.com/go-check/check latest
go: finding github.com/syndtr/gocapability latest
go: finding github.com/samuel/go-zookeeper latest
go: finding github.com/niemeyer/pretty latest
go: finding github.com/tmc/grpc-websocket-proxy latest
go: finding github.com/golang/groupcache latest
go: finding github.com/xiang90/probing latest
go: finding google.golang.org/grpc/examples latest
go: go.etcd.io/bbolt@v1.3.5 used for two different module paths (github.com/coreos/bbolt and go.etcd.io/bbolt)

I cannot figure out how to get beyond this issue with the two different module paths.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (2 by maintainers)

Most upvoted comments

Yes, I removed the replace github.com/Sirupsen/logrus => github.com/siru line.

I then ran:

$ go clean

and then undid the changes. I then changed my go.mod file to:

module my-package

go 1.14

require (
	github.com/apache/pulsar-client-go v0.1.1
	github.com/docker/docker v17.12.0-ce-rc1.0.20200531234253-77e06fda0c94+incompatible
	github.com/sirupsen/logrus v1.6.0
	github.com/docker/swarmkit v1.12.1-0.20200604173159-967c829cdd33
	github.com/opencontainers/runc v1.0.0-rc9 //indirect
)

and ran: $ go mod tidy

and it finally worked!

Thanks for all the help here.