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: run gives conflicting advice when using path@version syntax #29415

Open
davecheney opened this Issue Dec 25, 2018 · 5 comments

Comments

Projects
None yet
7 participants
@davecheney
Copy link
Contributor

davecheney commented Dec 25, 2018

What version of Go are you using (go version)?

% go version
go version devel +97d5cb24b1 Sat Dec 22 09:37:04 2018 +0000 linux/amd64

Does this issue reproduce with the latest release?

unknown

What operating system and processor architecture are you using (go env)?

go env Output
% go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/dfc/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH=""
GOPROXY=""
GORACE=""
GOROOT="/home/dfc/go"
GOTMPDIR=""
GOTOOLDIR="/home/dfc/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build125128327=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Go 1.12beta1 (tip) does not permit @Version syntax unless modules explicitly enabled, even if GOPATH is unset

% unset GOPATH && go run -v github.com/davecheney/httpstat@1.0.0
package github.com/davecheney/httpstat@1.1.0: cannot use path@version syntax in GOPATH mode

What did you expect to see?

env GO111MODULE=on go run -v github.com/davecheney/httpstat@1.0.0

would download and build httpstat v1.0.0

What did you see instead?

% unset GOPATH && env GO111MODULE=on go run -v github.com/davecheney/httpstat@1.0.0
missing $GOPATH

Running without modules enabled tells me I must enable modules even thought I don't have GOPATH set. Running with modules enable tells me I must set GOPATH.

lucky(/tmp) % env GO111MODULE=on GOPATH=/tmp/ go run -v github.com/davecheney/httpstat@1.0.0
package github.com/davecheney/httpstat@1.0.0: can only use path@version syntax with 'go get'

Setting both tells me that this isn't supported.

a. Can go run path@version be supported? If not, why not?
b. Can the error messages be improved make it clearer sooner that the operation will not succeed once the correct permutation of environment variables is discovered.

@odeke-em

This comment has been minimized.

Copy link
Member

odeke-em commented Dec 27, 2018

Thank you for this report @davecheney!

Kindly paging @bcmills @rsc.

@odeke-em odeke-em changed the title go run gives conflicting advice when using path@version syntax cmd/go: run gives conflicting advice when using path@version syntax Dec 27, 2018

@jadekler

This comment has been minimized.

Copy link
Contributor

jadekler commented Jan 4, 2019

Seems to not be working for me, either:

$ cd /tmp/whatever && unset GOPATH && go get cloud.google.com/go@v0.30.0
go: cannot use path@version syntax in GOPATH mode
@ahmetb

This comment has been minimized.

Copy link

ahmetb commented Jan 4, 2019

Hit this as well in #29575. Closing that as duplicate.

@bcmills bcmills added this to the Go1.13 milestone Jan 8, 2019

@bcmills bcmills added the modules label Jan 8, 2019

@rsc

This comment has been minimized.

Copy link
Contributor

rsc commented Jan 10, 2019

Only go get and module-manipulation commands take path@version.
go build, go run, etc do not.

@jadekler

This comment has been minimized.

Copy link
Contributor

jadekler commented Jan 10, 2019

Go get does not take path@version for me. I've filed #29659, since that appears to be different from the go run case that this issue was describing. (happy to dedupe if you prefer the conversation to happen here)

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