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

Closed
mvdan opened this issue Feb 1, 2019 · 4 comments
Closed
Labels
FrozenDueToAge modules NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@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 mvdan added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. modules labels Feb 1, 2019
@mvdan
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
Copy link
Contributor

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.

@mvdan
Copy link
Member Author

mvdan commented Mar 22, 2019

I think we could close this issue if we had the command for #30515 error when given non-main packages.

@mvdan
Copy link
Member Author

mvdan commented Dec 1, 2019

Update - now go install always errors outside of a main module, and it's only go get that still works.

I think there's less reason to make go get foo.com/non/main/pkg error outside of a main module, because of that. Also, it would be weird to force the user to do go get -d in that case.

In any case, this issue was about my own confusion, and I no longer find the current situation confusing. Closing.

@mvdan mvdan closed this as completed Dec 1, 2019
@golang golang locked and limited conversation to collaborators Nov 30, 2020
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.
Projects
None yet
Development

No branches or pull requests

3 participants