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

dl/internal/version: not setting goroot #30126

Closed
AlexRouSg opened this issue Feb 7, 2019 · 14 comments
Closed

dl/internal/version: not setting goroot #30126

AlexRouSg opened this issue Feb 7, 2019 · 14 comments

Comments

@AlexRouSg
Copy link
Contributor

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

1.12beta2 but irreverent

Does this issue reproduce with the latest release?

Yes

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

set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\alexr\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=%USERPROFILE%\go
set GOPROXY=
set GORACE=
set GOROOT=C:\Go-tip
set GOTMPDIR=
set GOTOOLDIR=C:\Go-tip\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=%USERPROFILE%\AppData\Local\Temp\go-build619042602=/tmp/go-build -gno-record-gcc-switches

What did you do?

In an effort to reproduce the issue reported in #30117
I ran go get golang.org/dl/gotip followed by gotip run . on the code described in
#30117 (comment)

What did you expect to see?

No output

What did you see instead?

.\test.go:16:86: syntax error: unexpected semicolon, expecting expression

Setting GOROOT to the proper path gives the expected result.

@gopherbot gopherbot added this to the Unreleased milestone Feb 7, 2019
@bcmills
Copy link
Contributor

bcmills commented Feb 7, 2019

You may need to run go get -u golang.org/dl/gotip && gotip download to make sure you're on the version of the wrapper that sets it.

@AlexRouSg
Copy link
Contributor Author

right... forgot to mention I did gotip download

@bcmills
Copy link
Contributor

bcmills commented Feb 8, 2019

Did you run go get -u, with the -u flag?

@AlexRouSg
Copy link
Contributor Author

Never downloaded gotip on this machine before so didn't think it mattered. But just to be sure I did ran it with -u and no change.

gotip env does show GOROOT to be C:\Go instead of %USERPROFILE%\sdk\gotip

@mvdan
Copy link
Member

mvdan commented Feb 8, 2019

Are you setting GOROOT directly anywhere on your system?

@AlexRouSg
Copy link
Contributor Author

Nope, only set GOPATH nothing more.

@AlexRouSg
Copy link
Contributor Author

OHHH the windows installer set GOROOT under system variables and I didn't checked there.

Still one would assume gotip to set GOROOT no?

@mvdan
Copy link
Member

mvdan commented Feb 8, 2019

In general, Go installations nowadays should not set up GOROOT. It is inferred from the location of the go binary you are running.

If you do specify a GOROOT via an env var, it's always used directly. So if your system sets GOROOT, you'll also have to set it up when calling gotip or any other binary Go installation.

gotip doesn't set GOROOT because it isn't necessary. And presumably, also because users can set their own GOROOT, overriding the default.

So in this case, I'd say this is not a bug; you should either not have GOROOT set up, or you should set it up when calling gotip. But I'll leave the issue open for now, in case it's decided that there's something to fix in programs like gotip.

@AlexRouSg
Copy link
Contributor Author

If it's decided that there's nothing to do here I'm fine with that.

Should I file a new report for the official windows installer setting GOROOT?

@mvdan
Copy link
Member

mvdan commented Feb 8, 2019

Should I file a new report for the official windows installer setting GOROOT?

I'd do that; see https://golang.org/doc/go1.10#goroot. Setting it is usually harmless, but can be confusing when one uses multiple Go versions, like you're trying to do.

@mvdan
Copy link
Member

mvdan commented Feb 8, 2019

I've also sent https://go-review.googlesource.com/c/go/+/161758, as I still found pieces of the official documentation which recommeded setting up GOROOT.

@agnivade
Copy link
Contributor

agnivade commented Feb 9, 2019

Looks like this is tracked in the new issue. Closing.

@agnivade agnivade closed this as completed Feb 9, 2019
@AlexRouSg
Copy link
Contributor Author

@agnivade not exactly, they are related yes but quite different.

This issue is about whether x/dl/version should ignore a set GOROOT as the point of x/dl/version is to use a specific Go version.

@agnivade
Copy link
Contributor

agnivade commented Feb 9, 2019

x/dl/version just installs a go distribution. And the Go distribution will always use a GOROOT env var if it is specifically set. I don't think there is any bug here with x/dl/version.

@golang golang locked and limited conversation to collaborators Feb 9, 2020
@dmitshur dmitshur changed the title x/dl/version: not setting goroot dl/version: not setting goroot Jun 24, 2023
@dmitshur dmitshur changed the title dl/version: not setting goroot dl/internal/version: not setting goroot Jun 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants