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/go: Misleading err msg if vendors/modules.txt doesn't exist #53007

Open
drpaneas opened this issue May 20, 2022 · 2 comments · May be fixed by #53008
Open

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

drpaneas opened this issue May 20, 2022 · 2 comments · May be fixed by #53008
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@drpaneas
Copy link

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.

drpaneas added a commit to drpaneas/go that referenced this issue May 20, 2022
The existing implementation is producing log.Fatalf err message but
that codepath is never touched, because the conditional statement
is wrong.

Fixes golang#53007
drpaneas added a commit to drpaneas/go that referenced this issue May 20, 2022
The existing implementation is producing log.Fatalf err message but
that codepath is never touched, because the conditional statement
is wrong.

Fixes golang#53007
@gopherbot
Copy link

Change https://go.dev/cl/407474 mentions this issue: cmd/go: improve err msg when vendors dir is missing but required

@seankhliao seankhliao added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. GoCommand cmd/go labels May 20, 2022
@seankhliao
Copy link
Member

cc @bcmills @matloob

@seankhliao seankhliao added this to the Unplanned milestone Aug 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants