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

doc: mention how to add GOPATH\bin to PATH for Windows users #18583

Closed
rakyll opened this issue Jan 9, 2017 · 11 comments
Closed

doc: mention how to add GOPATH\bin to PATH for Windows users #18583

rakyll opened this issue Jan 9, 2017 · 11 comments
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-Windows
Milestone

Comments

@rakyll
Copy link
Contributor

rakyll commented Jan 9, 2017

GOPATH variable section is not mentioning that GOPATH\bin needs to be added to PATH for convince. Create a wiki page with platform specific instructions how to add the bin directory to the PATH and add instructions for Windows.

@rakyll rakyll added this to the Go1.8Maybe milestone Jan 9, 2017
@bradfitz
Copy link
Contributor

bradfitz commented Jan 9, 2017

We need to stop adding stuff to Go 1.8. Let's target Go 1.9.

@bradfitz bradfitz modified the milestones: Go1.9, Go1.8Maybe Jan 9, 2017
@a-h
Copy link
Contributor

a-h commented Jun 7, 2017

The Windows installer does this automatically, so maybe this isn't required?

See: https://golang.org/doc/install?download=go1.8.3.windows-amd64.msi

Screen capture of the page at 7 June 2017:

screen shot 2017-06-07 at 10 10 18

@yspreen
Copy link

yspreen commented May 25, 2018

@a-h Maybe I'm mistaken, but GOPATH\bin is not c:\Go\bin?

@a-h
Copy link
Contributor

a-h commented May 25, 2018

Yes, you're right. On Windows %GOPATH%\bin is %USERPROFILE%\go, so if your Windows Username is Administrator, then your GOPATH would be C:\Users\Administrator\Go by default.

For Windows, I checked what happens if you install Go 1.10.2 on a new Windows Server 2016 VM running in AWS.

I can see that %GOPATH%\bin is added to the path by the installer by default:

screen shot 2018-05-25 at 14 47 41

So, for Windows, no documentation improvement is probably needed, I don't know whether the installation process for Linux or MacOS include this helpful step though.

@yspreen
Copy link

yspreen commented May 27, 2018

Very strange, for me that Path was not added it seems @a-h

I have two points of measurement, one from a few months back, so that might not be accurate anymore. But I also installed go very recently on a new machine, with no %GOPATH%\bin in fact.
I have to say though, I installed using chocolatey, so maybe my experience is different.

@deadprogram
Copy link

Just ran the MSI install of Go 1.10.3 on a clean Win10 VM. Although %GOPATH%\bin is added and appears in the list of paths in the editor, it does not get expanded correctly to the value of the GOPATH variable, probably due to missing ending semi-colon ala https://serverfault.com/questions/300544/environment-variables-in-path-not-expanded-for-non-admin-command-prompt#300591

The result of this is that go install and friends run correctly, however the resulting binary files are not in the Windows path and so cannot be run from any directory besides where the .exe file is located.

If someone could kindly point me towards where the script that builds the MSI file is located, I'd be happy to take a look.

@alexbrainman
Copy link
Member

If someone could kindly point me towards where the script that builds the MSI file is located

I think you want $GOPATH/src/golang.org/x/build/cmd/release/releaselet.go

Alex

@deadprogram
Copy link

deadprogram commented Aug 1, 2018

Thanks @alexbrainman that is it.

Specifically, this line: https://github.com/golang/build/blob/master/cmd/release/releaselet.go#L732

By changing that line from this

Value="%GOPATH%\bin" />

to this instead

Value="%USERPROFILE%\go\bin" />

then the MSI installer modifies the PATH correctly, and no further effort is required from the user.

Otherwise, the user must open the "Control Panel -> Edit environment variables for your account" from the "Start" menu and click on the "OK" button in the dialog. Once this has been done, the user can open a new command window, and the path will be set correctly.

The above is via http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Setting-environment-variable-PATH-tp2418484p5264135.html

@gopherbot
Copy link

Change https://golang.org/cl/127777 mentions this issue: cmd/release: use %USERPROFILE% instead of %GOPATH% in PATH

@alexbrainman
Copy link
Member

By changing that line from this

Value="%GOPATH%\bin" />
to this instead

Value="%USERPROFILE%\go\bin" />

Done. Please, review my change https://go-review.googlesource.com/c/build/+/127777.

Alex

@ALTree ALTree added the NeedsFix The path to resolution is known, but the work has not been done. label Sep 22, 2018
@ALTree
Copy link
Member

ALTree commented Sep 22, 2018

The GOPATH section now mentions adding GOPATH/bin and it links to https://github.com/golang/go/wiki/SettingGOPATH#windows which has instruction on how to do so on windows; so this is fixed. Closing.

@ALTree ALTree closed this as completed Sep 22, 2018
gopherbot pushed a commit to golang/build that referenced this issue Oct 24, 2018
CL 104115 added %GOPATH%\bin to the PATH. But GOPATH environment
variable might contain directory list. So, if, for example, GOPATH has
"c:\a;c:\b", then PATH is end up with "c:\a;c:\b\bin" - which is wrong -
user, probably, wants both c:\a\bin and c:\b\bin to be listed in his/her
PATH.

Use %USERPROFILE%\go\bin instead, because USERPROFILE always has
directory.

If user wants to change GOPATH, they would have to adjust their PATH
manually.

Updates golang/go#18583

Change-Id: I634a25ace28776c978faebcfcb2c1750d6d17a0d
Reviewed-on: https://go-review.googlesource.com/c/127777
Reviewed-by: Ron Evans <ron@hybridgroup.com>
Reviewed-by: Mario Arranz <marioarranzr@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
@golang golang locked and limited conversation to collaborators Sep 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done. OS-Windows
Projects
None yet
Development

No branches or pull requests

10 participants