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: exclude $GOPATH/src/mod from “all” and “...” patterns in GOPATH mode #26401

Closed
bcmills opened this issue Jul 16, 2018 · 10 comments
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Jul 16, 2018

After performing a go build in module mode, go build all in GOPATH mode emits a bunch of errors due to import path mismatches in $GOPATH/src/mod.

Since the code in $GOPATH/src/mod isn't intended to be buildable in GOPATH mode in the first place, we should explicitly ignore it.

~/src$ cd $GOPATH/src

~/src$ go get rsc.io/sampler

~/src$ pushd rsc.io/sampler
~/src/rsc.io/sampler ~/src

~/src/rsc.io/sampler$ GO111MODULE=on go build .
go: finding golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c
go: downloading golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c

~/src/rsc.io/sampler$ popd
~/src

~/src$ GO111MODULE=off go build all 2>&1 | grep mod/ | head -n 10
can't load package: package mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c: disallowed import path "mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c"
can't load package: package mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/cases: disallowed import path "mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/cases"
can't load package: package mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/cmd/gotext: disallowed import path "mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/cmd/gotext"
can't load package: package mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/collate: disallowed import path "mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/collate"
can't load package: package mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/collate/build: disallowed import path "mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/collate/build"
can't load package: package mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/collate/tools/colcmp: disallowed import path "mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/collate/tools/colcmp"
can't load package: package mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/currency: disallowed import path "mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/currency"
can't load package: package mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/encoding: disallowed import path "mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/encoding"
can't load package: package mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/charmap: disallowed import path "mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/charmap"
can't load package: package mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/htmlindex: disallowed import path "mod/golang.org/x/text@v0.0.0-20170915032832-14c0d48ead0c/encoding/htmlindex"

(CC: @rsc)

@bcmills bcmills added this to the Go1.11 milestone Jul 16, 2018
@bcmills bcmills changed the title cmd/go: exclude $GOPATH/src/mod from “all” pattern in GOPATH mode cmd/go: exclude $GOPATH/src/mod from “all” and “...” patterns in GOPATH mode Jul 16, 2018
@rsc
Copy link
Contributor

rsc commented Jul 17, 2018

Yes, mod should just be invisible in GOPATH/src. That's in internal/search I think.

@rsc
Copy link
Contributor

rsc commented Jul 17, 2018

We could plausibly backport the GOPATH/src/mod exclusion to Go 1.9 and Go 1.10 as well.

@gopherbot
Copy link

Change https://golang.org/cl/125675 mentions this issue: cmd/go: exclude import paths beginning with mod/ from patterns

@anacrolix
Copy link
Contributor

Any reason this stuff can't go in $GOPATH/mod or something other than $GOPATH/src? I posted to golang-dev just now on this.

@davecheney
Copy link
Contributor

davecheney commented Jul 25, 2018 via email

@anacrolix
Copy link
Contributor

How do those people setting $GOPATH=$HOME rationalize pkg? .mod seems good if the existing tools work with that.

@bcmills
Copy link
Contributor Author

bcmills commented Jul 25, 2018

How do those people setting $GOPATH=$HOME rationalize pkg?

I mostly close my eyes and pretend it isn't there. (And soon it won't be! See #4719.)

@anacrolix
Copy link
Contributor

Regarding the CL: It would be nice if "mod" was a constant somewhere. Similarly for its use elsewhere in the code base.

@bcmills bcmills added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jul 30, 2018
@bcmills
Copy link
Contributor Author

bcmills commented Jul 30, 2018

On hold pending a decision on whether to move the module cache someplace where it would be ignored by default (outside of $GOPATH/src or in a subdirectory beginning with . or _).

@bcmills bcmills self-assigned this Jul 30, 2018
@gopherbot
Copy link

Change https://golang.org/cl/126755 mentions this issue: cmd/go: move module cache from $GOPATH/src/mod to $GOPATH/pkg/mod

@golang golang locked and limited conversation to collaborators Aug 1, 2019
@rsc rsc unassigned bcmills Jun 23, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Projects
None yet
Development

No branches or pull requests

5 participants