-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/internal: panic, "GOROOT not set in evaluated environment" #40670
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
Comments
I'm using Go |
/cc @heschik |
Please run |
|
Huh, I really expected that to be more useful. Okay. Don't bother setting GOROOT, that's only confusing the situation. Please run |
$ go env -json GO111MODULE GOFLAGS GOINSECURE GOMOD GOMODCACHE GONOPROXY GONOSUMDB GOPATH GOPROXY GOROOT GOSUMDB
{
"GO111MODULE": "off",
"GOFLAGS": "",
"GOINSECURE": "",
"GOMOD": "",
"GOMODCACHE": "/Users/kevin/pkg/mod",
"GONOPROXY": "github.com/meterup",
"GONOSUMDB": "github.com/meterup",
"GOPATH": "/Users/kevin",
"GOPROXY": "direct",
"GOROOT": "/Users/kevin/go",
"GOSUMDB": "sum.golang.org"
} |
Did you try to reproduce it using the example above? Can you reproduce it? |
Change https://golang.org/cl/247797 mentions this issue: |
Apologies, I didn't give much credit to the idea that goimports had been broken for over a month or however long it's been. Fix above. |
Well, I could only trigger it if the package name matched the stdlib package I was trying to import, if I named the package something else there wouldn't be a panic. |
I put the following in a file named
filename.go
(filename doesn't matter):I then run
GOROOT=/Users/kevin/go goimports .
I expect that the"archive/zip"
import will be added to the import section. Instead I get a panic:Note I have explicitly set GOROOT in the environment. Adding a print statement to the relevant line in
fix.go
, it looks likee.Env
is nil at the point where it expects to be readingGOROOT
.The package name must match the imports, I think, you can also reproduce if you replace
zip
withio
in all three places, but you can't reproduce if you replaceio
in one place and keepzip
in the other place.I'm able to reproduce this on
x/tools
tip as well as on the commit taggedgopls/v0.4.4
.The text was updated successfully, but these errors were encountered: