GoogleCloudPlatform / artifact-registry-go-tools

Apache License 2.0
8 stars 6 forks source link

Support Windows _netrc instead of .netrc #14

Open veggiemonk opened 1 year ago

veggiemonk commented 1 year ago

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/modulename@v0.0.1: 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 commented 11 months ago

@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 commented 5 months ago

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