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

x/vgo: netrc failing to load on Windows, possibly in wrong place #24606

Closed
rsc opened this issue Mar 30, 2018 · 5 comments
Closed

x/vgo: netrc failing to load on Windows, possibly in wrong place #24606

rsc opened this issue Mar 30, 2018 · 5 comments
Labels
FrozenDueToAge NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@rsc
Copy link
Contributor

rsc commented Mar 30, 2018

On Windows $HOME/.netrc is the wrong path; at the least there's no $HOME.
We should find out what the canonical path is on Windows and use that.

See #23955 (comment) by @doxxx.

@rsc rsc added this to the vgo milestone Mar 30, 2018
@rsc rsc added the NeedsFix The path to resolution is known, but the work has not been done. label Mar 30, 2018
@doxxx
Copy link

doxxx commented Mar 30, 2018

On Windows, the equivalent of $HOME is $USERPROFILE. I do also have a HOME env var defined, pointing at the same location as USERPROFILE. I've created a _netrc file in that location with these contents:

machine api.github.com
login doxxx
password TOKEN

I've verified using Windows Subsystem for Linux that vgo with a $HOME/.netrc containing the above does not encounter the Github rate limits even after multiple invocations of vgo get -u in quick succession.

@doxxx
Copy link

doxxx commented Mar 30, 2018

I just tried renaming the _netrc to .netrc in Windows and it appears to be working with the contents I described above. I had tried .netrc originally, but maybe I got the format wrong at the time?

To summarize, for this to work:

  • .netrc must be created in the user's profile directory (e.g. C:\Users\Gordon)
  • Line endings don't matter, both CRLF and LF work.
  • There must be a HOME env var containing the path to the user's profile directory. It doesn't work if this is not defined.
  • The .netrc must use your Github username for the login and your generated Github auth token for the password.

@kardianos
Copy link
Contributor

You can't directly use the $HOME env var, go through user PKG. As indicated above, windows expects the name to be "_netrc". At least this is how git code review and windows git work.

@kardianos
Copy link
Contributor

Yes, this line in vgo internal web2/web.go is wrong.
filepath.Join(os.Getenv("HOME"), ".netrc")

Use how code review does it:
https://github.com/golang/review/blob/0bdc7edde01a92e96255c6845b536d59706b9542/git-codereview/api.go#L130

@gopherbot
Copy link

Change https://golang.org/cl/103866 mentions this issue: x/vgo: netrc failing to load on Windows, possibly in wrong place

@golang golang locked and limited conversation to collaborators Apr 3, 2019
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

4 participants