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

Support Windows _netrc instead of .netrc #14

Open
veggiemonk opened this issue Oct 30, 2023 · 5 comments
Open

Support Windows _netrc instead of .netrc #14

veggiemonk opened this issue Oct 30, 2023 · 5 comments

Comments

@veggiemonk
Copy link

Hi,

I found a bug for Windows (I don't use it by choice).

The error message is:

go: downloading example.com/modulename v0.0.1
go: othermodule/name imports
        example.com/modulename: example.com/[email protected]: reading https://LOCATION-go.pkg.dev/PROJECT_ID/REPOSITORY/example.com/modulename/@v/v0.0.1.zip: 401 Unauthorized
server response: The request does not have valid authentication credentials. If you are running github.com/GoogleCloudPlatform/artifact-registry-go-tools, make sure to add it to the GONOPROXY environment variable. Refer to https://go.dev/ref/mod#private-module-privacy for more information.

As stated in the reference for modules https://go.dev/ref/mod#private-module-proxy-auth

The location of the file may be set with the NETRC environment variable. 
If NETRC is not set, the go command will read $HOME/.netrc on UNIX-like platforms 
or %USERPROFILE%\_netrc on Windows.

I solved it by just copying the file and changing the name to _netrc

It should probably be stressed out in the Artifact Registry documentation: https://cloud.google.com/artifact-registry/docs/go/store-go

Let's really hope this helps someone save hours of debugging (like I just did) 😆

@yihanzhen
Copy link
Member

@veggiemonk thanks for reporting! It would be much appreciated if you would like to prepare a CL :) Otherwise I'll get to it whenever I have a chance.

@roger-canann
Copy link

Glad I found this! Spent quite some time trying to get this to work -- and this resolved it for me.

@cagataygurturk
Copy link
Contributor

cagataygurturk commented Jan 21, 2025

You can set the NETRC environment variable to $HOME/.netrc for go to workaround this.

@cagataygurturk cagataygurturk mentioned this issue Jan 21, 2025
3 tasks
@cagataygurturk
Copy link
Contributor

Hi again, I believe #20 adresses this issue

yihanzhen pushed a commit that referenced this issue Feb 6, 2025
- Fixes Support Windows _netrc instead of .netrc #14
- Switch from path to path/filepath for multi-platform line separators
- Fix the AddConfigs test for Windows by removing the new lines in the test data. Different new line characters in Windows were causing tests always to fail
@cagataygurturk
Copy link
Contributor

The issue now must have been solved with the version 0.4.0

@yihanzhen https://cloud.google.com/artifact-registry/docs/go/authentication is still referring to 0.1.0. Generally, this documentation assumes Unix-like operating systems with all the command examples.

Could you internally raise this so it is updated?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants