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: reject vendor directories as module-mode build arguments unless -mod=vendor is set #32921

Closed
bcmills opened this issue Jul 3, 2019 · 1 comment
Labels
FrozenDueToAge modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@bcmills
Copy link
Contributor

bcmills commented Jul 3, 2019

There is a TODO here yet to be done:

if strings.HasPrefix(suffix, "/vendor/") {
// TODO getmode vendor check
pkg = strings.TrimPrefix(suffix, "/vendor/")

The effect of the missing check is that when -mod=vendor is not set, running go build or go test with an empty directory path beginning with ./vendor causes the go command to resolve and download the corresponding module, ignoring the contents of the vendor directory.

example.com$ go1.13beta1 mod init example.com
go: creating new go.mod: module example.com

example.com$ go1.13beta1 build ./vendor/golang.org/x/text/unicode
can't load package: package golang.org/x/text/unicode: unknown import path "golang.org/x/text/unicode": cannot find package

example.com$ mkdir -p vendor/golang.org/x/text/unicode

example.com$ go1.13beta1 build ./vendor/golang.org/x/text/unicode
go: finding golang.org/x/text v0.3.2
go: downloading golang.org/x/text v0.3.2
go: extracting golang.org/x/text v0.3.2

example.com$

(Found while investigating #32917.)

@bcmills bcmills added NeedsFix The path to resolution is known, but the work has not been done. modules labels Jul 3, 2019
@bcmills bcmills added this to the Go1.14 milestone Jul 3, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
@bcmills
Copy link
Contributor Author

bcmills commented Mar 2, 2020

Fixed by CL 185345.

@bcmills bcmills closed this as completed Mar 2, 2020
@bcmills bcmills modified the milestones: Backlog, Go1.15 Mar 2, 2020
@bcmills bcmills self-assigned this Mar 2, 2020
@golang golang locked and limited conversation to collaborators Mar 2, 2021
@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 NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants