-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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: better error message for GOPATH set to GOROOT has no effect #70093
Comments
The default for I'm going to close this because there is nothing to change in Go. If you want to discuss this, please use a forum; see https://go.dev/wiki/Questions. Thanks. |
@ianlancetaylor this comment is extremely salient: are you really not willing to admit that the current state is confusing? |
I certainly agree that the current state is confusing. What should we do about it? If your goal with this issue is to get a better error message, I would encourage you to state that explicitly. This bug report doesn't say what the problem is and it doesn't make any suggestion as to what would be better. It is quite possible that these are very obvious to you. That does not mean that they are obvious to us. Thanks. |
Why would I do that? You've made it clear you're more interested in shutting down discussion instead of fostering it. If you mean what you say, reopen the issue and I will help however I can |
You are absolutely correct about discussion: we've found that discussion on the issue tracker does not work. That's why we refer people to https://go.dev/wiki/Questions. The issue tracker is for bug reports. A bug report is a two-way street: we have to be able to understand what the problem is, and you have to take the time to explain the problem. It would be nice if we could just figure it out, but we can't. We are tiny team supporting millions of users. Help us out. |
the current summary by @tonymet does a great job in describing the current problem: in my opinion, nothing needs to be added to that. if someone need further detail I am happy to provide it. in short: some users are gonna get this warning and have no idea how to fix it, and the Go tool not only takes no action to help the problem, it doesn't even advise on an action. a simple "move your Go installation to another folder" or similar would go a long way |
Go Wiki: Setting GOPATH has a note:
However, it doesn't say what will happen when they're the same so it's hard for users to refer this note because there is no link between warning warning: GOPATH set to GOROOT (%s) has no effect and this go wiki part. We can consider to change 2 things: compiler message:The comment in L151 probably is better because user could easily know the behavior of GOPATH is not set by searching the GOPATH doc. Lines 150 to 153 in 67f1314
User could reach the go wiki about GOPATH and find the default behavior of GOPATH, and they can easily come up with a solution by specifying GOPATH to another place.
// main.go:
- fmt.Fprintf(os.Stderr, "warning: GOPATH set to GOROOT (%s) has no effect\n", gopath)
+ fmt.Fprintf(os.Stderr, "warning: GOPATH set to GOROOT (%s) has no effect and it is equivalent to not setting GOPATH at all \n", gopath)
go wiki:After changing the go error message, we can consider to add more details for Note that GOPATH must not be the same path as your Go installation. I prefer to add 2 parts:
// go wiki
Note that GOPATH must not be the same path as your Go installation.
+Consider to set GOPATH to another place which differs from GOROOT
+if you encountered a warning "GOPATH set to GOROOT...". In this user case, users GOROOT and GOPATH are the same, so go compiler will try to use HDYT? @ianlancetaylor @3052 If you think that's reasonable, I will send a CL in go. But need @ianlancetaylor help to amend go wiki because it requires the member role in golang organization and I'm not a member:( |
I dont think this goes far enough. the root cause here is the user has put their Go installation in the wrong place, so the message should reflect that. if user is determined then the fix could be messing with |
I improved https://go.dev/wiki/InstallTroubleshooting, and sent https://go.dev/cl/623815 to change the error message to point to that wiki page. |
Change https://go.dev/cl/623815 mentions this issue: |
Go version
go version go1.23.2 windows/amd64
Output of
go env
in your module/workspace:What did you do?
repost because previous issue was closed in error
go version
What did you see happen?
warning: GOPATH set to GOROOT (C:\Users\spenny\go) has no effect
go version go1.23.2 windows/amd64
What did you expect to see?
go version go1.23.2 windows/amd64
note I also tried to unset both values:
PS C:\Users\spenny\Desktop> go env -u GOROOT
warning: GOPATH set to GOROOT (C:\Users\spenny\go) has no effect
PS C:\Users\spenny\Desktop> go env -u GOPATH
warning: GOPATH set to GOROOT (C:\Users\spenny\go) has no effect
PS C:\Users\spenny\Desktop> go version
warning: GOPATH set to GOROOT (C:\Users\spenny\go) has no effect
go version go1.23.2 windows/amd64
also:
PS C:\Users\spenny\Desktop> go env -changed
warning: GOPATH set to GOROOT (C:\Users\spenny\go) has no effect
The text was updated successfully, but these errors were encountered: