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: 'install' succeeds without a main module when given a non-main package #30053

Open
mvdan opened this Issue Feb 1, 2019 · 2 comments

Comments

Projects
None yet
2 participants
@mvdan
Copy link
Member

mvdan commented Feb 1, 2019

https://go-review.googlesource.com/c/go/+/148517 works great, for the most part. I found this behavior, which confused me a bit.

$ go version
go version devel +faf187fb8e Thu Jan 31 16:55:43 2019 +0000 linux/amd64
$ export GO111MODULE=on
$ go env GOMOD
/dev/null
$ go install mvdan.cc/xurls/v2
$ echo $?
0
$ go list -f {{.Name}} mvdan.cc/xurls/v2
xurls

Sounds to me like this should error; install shouldn't behave just like get -d when given non-main packages.

Similarly, go get mvdan.cc/xurls/v2 succeeds, but I presume it should fail. Only go get -d mvdan.cc/xurls/v2 should succeed.

/cc @bcmills @myitcv

@mvdan

This comment has been minimized.

Copy link
Member Author

mvdan commented Feb 1, 2019

@rogpeppe points out that the root directory is a non-main package with some files, so the commands were actually doing something - presumably filling up the build cache.

However, perhaps there should be a way to globally say "install this binary", which would error if erroneously given non-main packages. I had run the wrong command, and I was confused for a while as to why no binary was being installed.

But perhaps it's just me who has been confused by this :)

@bcmills bcmills added this to the Unplanned milestone Feb 12, 2019

@bcmills

This comment has been minimized.

Copy link
Member

bcmills commented Feb 12, 2019

We haven't seen many reports of confusion with this so I don't think it's a priority for 1.13, but perhaps we can revisit when folks are more used to go install not being a command that is ever particularly useful to run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment