Skip to content

vendor: run go mod tidy and go mod vendor#44615

Closed
paralin wants to merge 1 commit intomoby:masterfrom
paralin:run-go-mod-vendor
Closed

vendor: run go mod tidy and go mod vendor#44615
paralin wants to merge 1 commit intomoby:masterfrom
paralin:run-go-mod-vendor

Conversation

@paralin
Copy link
Copy Markdown

@paralin paralin commented Dec 8, 2022

Run "go mod tidy" and "go mod vendor" to fix the (currently broken) go.sum file and the vendor/ tree.

Fixes errors when running go build -mod=vendor

go: inconsistent vendoring in docker-engine-:
  cloud.google.com/[email protected]: is marked as explicit in vendor/modules.txt, but not explicitly required in go.mod
  cloud.google.com/go/[email protected]: is marked as explicit in vendor/modules.txt, but not explicitly required in go.mod
  cloud.google.com/go/[email protected]: is marked as explicit in vendor/modules.txt, but not explicitly required in go.mod
  code.cloudfoundry.org/[email protected]: is marked as explicit in vendor/modules.txt, but not explicitly required in go.mod
  [snip]

  To ignore the vendor directory, use -mod=readonly or -mod=mod.
  To sync the vendor directory, run:
  go mod vendor

Fixes #44614

Run "go mod tidy" and "go mod vendor" to fix the (currently broken) go.sum file
and the vendor/ tree.

Fixes errors when running "go mod vendor":

go: inconsistent vendoring in docker-engine-:
  cloud.google.com/[email protected]: is marked as explicit in vendor/modules.txt, but not explicitly required in go.mod
  cloud.google.com/go/[email protected]: is marked as explicit in vendor/modules.txt, but not explicitly required in go.mod
  cloud.google.com/go/[email protected]: is marked as explicit in vendor/modules.txt, but not explicitly required in go.mod
  code.cloudfoundry.org/[email protected]: is marked as explicit in vendor/modules.txt, but not explicitly required in go.mod
  [snip]

  To ignore the vendor directory, use -mod=readonly or -mod=mod.
  To sync the vendor directory, run:
  go mod vendor

Fixes moby#44614

Signed-off-by: Christian Stewart <[email protected]>
@thaJeztah
Copy link
Copy Markdown
Member

The reason you're running into this is that this repository is not yet a go module, as the versioning and package name are not compatible with Go's conventions; adding a go.mod would break the repository currently until we rename the project.

we use a vendor.mod file to specify the dependencies (which is a custom name for go.mod), which is used through the hack/vendor.sh script (which creates a temporary go.mod file to use during vendoring, but is not used after that); also see #44497

closing this because of that, but feel free to continue the conversation

@thaJeztah thaJeztah closed this Dec 8, 2022
@paralin
Copy link
Copy Markdown
Author

paralin commented Dec 8, 2022

@thaJeztah Previous releases build correctly with go build -mod=vendor but master and the latest beta release do not.

Please fix this so that we don't have to change our entire build tooling in Buildroot just for this package.

@thaJeztah
Copy link
Copy Markdown
Member

Previous releases didn't use the go mod tool for performing the vendor, so didn't put a modules.txt inside the vendor directory, which is probably what trips up what you saw; you should be able to build this with GO111MODULE=off if the source is in GOPATH

@paralin
Copy link
Copy Markdown
Author

paralin commented Dec 8, 2022

@thaJeztah That causes a couple more issues:

  • We set modcacherw which causes a go tool error when GO111MODULE=off
  • We rely on the module path matching to find the path to cmd/docker as github.com/docker/docker/cmd/docker

... overall this causes a bit of a nightmare on our end.

@paralin
Copy link
Copy Markdown
Author

paralin commented Dec 8, 2022

@thaJeztah Seems like setting GO111MODULE=off also disables the vendor/ path lookup...

cmd/dockerd/daemon_unix.go:22:2: cannot find package "golang.org/x/sys/unix" in any of:
        /lib/go/src/golang.org/x/sys/unix (from $GOROOT)
        /host/share/go-path/src/golang.org/x/sys/unix (from $GOPATH)

Why can't it be the way it was before, which worked fine & played nice with the go mod infrastructure?

@thaJeztah
Copy link
Copy Markdown
Member

Does it work if you remove the modules.txt before building?

@paralin
Copy link
Copy Markdown
Author

paralin commented Dec 8, 2022

@thaJeztah That works & is a reasonable workaround. Thanks.

@paralin paralin deleted the run-go-mod-vendor branch December 8, 2022 23:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[23.0.0-beta] go.sum and vendor/ tree currently mismatch go.mod

2 participants