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: support both .netrc and _netrc under windows #66832

Open
hauserx opened this issue Apr 15, 2024 · 1 comment
Open

cmd/go: support both .netrc and _netrc under windows #66832

hauserx opened this issue Apr 15, 2024 · 1 comment
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.

Comments

@hauserx
Copy link

hauserx commented Apr 15, 2024

Go version

go version go1.22.1 windows/amd64

Output of go env in your module/workspace:

set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\xxx\AppData\Local\go-build
set GOENV=C:\Users\xxx\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\xxx\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\aep2rh\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.22.1
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=0
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\xxx\AppData\Local\Temp\go-build3364902034=/tmp/go-build -gno-record-gcc-switches

What did you do?

I have %USERPROFILE%\.netrc with proper credentials, and then:

set GOPROXY=https://<my_proxy>
go clean -modcache
go mod download -json gopkg.in/yaml.v3@v3.0.1

What did you see happen?

... gopkg.in/yaml.v3/@v/v3.0.1.info: 401 Unauthorized

What did you expect to see?

Download succeeds. It works if I copy:

%USERPROFILE%\.netrc
to
%USERPROFILE%\_netrc

Code in go expects _netrc:

base = "_netrc"

While e.g. curl library (used by e.g. git and other tools) reads first .netrc file and fallbacks to _netc if not found:
https://github.com/curl/curl/blob/49f83c30e43749752072c65a43d553eb015453d1/docs/cmdline-opts/netrc.md?plain=1#L28
This functionality was added in curl/curl@f9c7ba9

Found issue when adding go support to some tooling, everything else was working but not go.
There seem to be no one convention how those files should be named (e.g. bazel seems to look only for .netrc - code), but probably being compatible with curl way is most appropriate.

For reference, issue on go that lead to adding support of _netrc under windows: #24606

@cherrymui cherrymui added GoCommand cmd/go NeedsFix The path to resolution is known, but the work has not been done. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed NeedsFix The path to resolution is known, but the work has not been done. labels Apr 15, 2024
@cherrymui
Copy link
Member

cc @matloob @samthanawalla

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

2 participants