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

cmd/go: env -w with bad GOPATH makes go env unusable #35338

Closed
xlionet opened this issue Nov 4, 2019 · 8 comments
Closed

cmd/go: env -w with bad GOPATH makes go env unusable #35338

xlionet opened this issue Nov 4, 2019 · 8 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@xlionet
Copy link

xlionet commented Nov 4, 2019

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

$ go version
go 1.13

Does this issue reproduce with the latest release?

not sure

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

go env Output
$ go env
go: GOPATH entry cannot start with shell metacharacter '~': "~/go"

What did you do?

go env -w GOPATH="~/go"

then

go env

What did you expect to see?

If "~" character is not allowed, prevent me before setting may more clearly!

What did you see instead?

go env is broken.

$ go env
go: GOPATH entry cannot start with shell metacharacter '~': "~/go"
@ALTree
Copy link
Member

ALTree commented Nov 4, 2019

Thanks for reporting this.

This is another variant of #34194 (env -w wit bad GOOS/GOARCH) and #34880 (env -w with bad GO111MODULE).

@ALTree ALTree changed the title go env not work when a invalid var was setted! cmd/go: env -w with bad GOPATH makes go env unusable Nov 4, 2019
@ALTree ALTree added the NeedsFix The path to resolution is known, but the work has not been done. label Nov 4, 2019
@ALTree ALTree added this to the Go1.14 milestone Nov 4, 2019
@xlionet
Copy link
Author

xlionet commented Nov 4, 2019

And how to solve this problem now, reinstall go? @ALTree

@ALTree
Copy link
Member

ALTree commented Nov 4, 2019

And how to solve this problem now, reinstall go?

You can manually set GOPATH to temporarily fix go env, then use go env -w again (with a correct path). So:

$ export GOPATH=/home/alberto/myfolder

now go env should work again, so you can do:

$ go env -w GOPATH=/home/alberto/myfolder

@xlionet
Copy link
Author

xlionet commented Nov 4, 2019

Thanks brother!

@xlionet xlionet closed this as completed Nov 4, 2019
@ALTree
Copy link
Member

ALTree commented Nov 4, 2019

Even if the workaround works, we probably should fix this by preventing the setting of bad GOPATH values. Let's keep this open to track that.

@ALTree ALTree reopened this Nov 4, 2019
@xlionet
Copy link
Author

xlionet commented Nov 4, 2019

@xlionet ok, it couldn`t be better!

@gopherbot
Copy link

Change https://golang.org/cl/205779 mentions this issue: cmd/go: refuse -w with an invalid GOPATH

@ghost
Copy link

ghost commented Jan 22, 2020

Well, on ubuntu you can find env file in the folder /home/vikram/.config/go. Just delete it or modify it in a text editor.

@golang golang locked and limited conversation to collaborators Jan 21, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

3 participants