-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: allow "go get" when outside a module in module mode #24250
Comments
@smyrman I think this is a genuine concern, but it isn't just about pulling down a specific version of a program; it is using vgo outside the context of a module. You'll get the same error if you omit the versuib Maybe: |
@kardianos, thanks for the response. I am actually not concerned about the error message being unclear. This is meant as a feature request to (somehow) still be able to install binaries to a user's PATH, no matter what your current working directory is, similar to what we can with I am not to particular about the syntax, but maybe there could be a flag like
While OS package managers are good at doing more or less the same thing (not to a user's home of course, but system wide), there is often a delay for programs to be packaged, and language power users may prefer to use a language package manger for installing his/hers software, while also being able to pull down unreleased software, as we do today with Further, even though |
PS! I am also not concerned about this issue being solved right away, but it would be really cool to solve it before vgo goes main-line, if that's what going to happen. |
Updated the description. |
This clearly must work eventually. The thing I'm not sure about is exactly what this does as far as the version is concerned: does it create a temporary module root and go.mod, do the install, and then throw it away? Probably. But I'm not completely sure, and for now I didn't want to confuse people by making vgo do things outside go.mod trees. Certainly the eventual go command integration has to support this. Note that installs already happen to $GOBIN or else $GOPATH/bin (so default $HOME/go/bin), not the modue tree. Will mark NeedsDecision because we still need to work out how to do this, but yes absolutely the command must work. |
This is a reasonable approach, and have some obvious benefits, such as the result of I suppose an alternative would be to have a "default" module that is used when a flag is provided to the E.g. one could picture a default module in #!/bin/sh
set -e
_module_path=$(echo $GOPATH | awk -F':' '{ print $1}')/src/u
mkdir -p ${_module_path}
cd ${_module_path}
test -f go.mod || echo 'module "u"' > go.mod
go get github.com/golang/dep/cmd/dep@v0.4.1 Some benefits
Major drawback
ConclusionFor me, I belive the drawback outweighs any benefit, and a temporary module root / mod.go root is the semantically correct solution; perhaps implementation wise the temporary module root and go.mod file only exists in memory. |
This isn't blocking Go 1.11. The main reason being that if GO111MODULE=auto (the default) then we can't reasonably do anything with modules when outside a go.mod tree. That's the opt-in. And inside a go.mod tree this already works. |
I agree that this doesn't block Go 1.11, but I do think it should be a blocker for 1.12. There are a lot of repos that have READMEs saying "just run go get github.com/me/myrepo to install". That should continue to work once GO111MODULE changes to "on". |
Agreed. I've marked it as a release-blocker for 1.12. |
The fork is pinned at v1.6.5 which is the last release before influxdata/influxdb@f2898d1. The commit is part of the larger effort in influxdata/influxdb#10618 which makes a breaking change. We can't handle this with Go modules because of golang/protobuf#751, which in turn depends on golang/go#24250 which will be fixed with go1.12. Change-Id: I43b643fcab202d94bd529dfce135fb4e3f5add52
Regarding @cespare's comment
This seems to be a major missing feature. Its nice things work concurrently now but sometimes you're in your project directory and want to download a tool. What should I do in this case? Just cd to a tmp dir? |
Nvm. To anyone wondering about my question in the future: https://github.com/go-modules-by-example/index/blob/master/010_tools/README.md |
This is to work around golang/go#24250.
UPDATE: This is a feature request to be able to install a program/main package to a user's home directory (basically $GOBIN) outside of a module context.
Background
While
dep
,glide
and other tools provide a way of fetching project dependencies, part of what they are missing which I think belongs in any officialgo get
with versioning, is a way to install programs (tools, CLI, or a binary compiled from any main package) into a user's PATH (e.g. GOBIN, which may be relevant, even if GOPATH get's deprecated).Please answer these questions before submitting your issue. Thanks!
What did you do?
Example command only; but this would be the closest to how things currently work with
go get
.What did you expect to see?
dep
binary (in this case) installed to either$GOBIN
,$GOPATH[0]/bin
or$HOME/go/bin
, in that order.What did you see instead?
$ vgo get github.com/golang/dep/cmd/dep@v0.4.1 cannot determine module root; please create a go.mod file there
System details
The text was updated successfully, but these errors were encountered: