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
Milestone

Comments

@xlionet
Copy link

@xlionet 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

This comment has been minimized.

Copy link
Member

@ALTree 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 label Nov 4, 2019
@ALTree ALTree added this to the Go1.14 milestone Nov 4, 2019
@xlionet

This comment has been minimized.

Copy link
Author

@xlionet xlionet commented Nov 4, 2019

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

@ALTree

This comment has been minimized.

Copy link
Member

@ALTree 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

This comment has been minimized.

Copy link
Author

@xlionet xlionet commented Nov 4, 2019

Thanks brother!

@xlionet xlionet closed this Nov 4, 2019
@ALTree

This comment has been minimized.

Copy link
Member

@ALTree 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

This comment has been minimized.

Copy link
Author

@xlionet xlionet commented Nov 4, 2019

@xlionet ok, it couldn`t be better!

@gopherbot

This comment has been minimized.

Copy link

@gopherbot gopherbot commented Nov 7, 2019

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

@gopherbot gopherbot closed this in f6ff806 Nov 8, 2019
@v-i-k-r-a-m

This comment has been minimized.

Copy link

@v-i-k-r-a-m v-i-k-r-a-m 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.