Skip to content

cmd/go: Misleading err msg if vendors/modules.txt doesn't exist #53007

@drpaneas

Description

@drpaneas

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

The bug was originally discovered with using Go 1.17.5 while we were trying to setup a CI for our Go project.

It is also reproducible with the latest release and build, such as:

go version devel go1.19-8542bd8938 Thu May 19 19:32:35 2022 +0000 darwin/amd64

What did you do?

  1. Go to any of your Go projects: cd $GOPATH/src/github.com/foo/bar
  2. Make sure you have modules enabled: export GO111MODULE=on
  3. Make sure you have vendor flag enabled: export GOFLAGS="-mod=vendor"
  4. Make sure there is no vendor directory there: rm -rf vendor or if you have rename it mv vendor backup_vendor.
  5. Run go fmt ./...

What did you expect to see?

I would expect to get an error:

go: open $GOPATH/src/github.com/foo/bar/vendor/modules.txt: no such file or directory

What did you see instead?

github.com/emicklei/go-restful/v3@v3.7.1: is explicitly required in go.mod, but not marked as explicit in vendor/modules.txt
... 
...
...
(skip the rest of them for brevity)
...
	To ignore the vendor directory, use -mod=readonly or -mod=mod.
	To sync the vendor directory, run:
		go mod vendor

It complains about my modules (actually, for every single one of them) that are not in-sync with my vendors, but this comparison never happens in the first place since there's no vendor/modules.txt to compare with.

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions