-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
GoCommandcmd/gocmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Description
Go version
go version go1.23.4 linux/amd64
Output of go env
in your module/workspace:
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.4'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/root/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='0'
GOMOD='/root/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build4127018846=/tmp/go-build -gno-record-gcc-switches'
What did you do?
This is exactly the same as #65041 with thedifference that this issue concerns the global gitconfig ~/.gitconfig
instead of the local .git/config
, recreated as #65041 was closed due to the particular decision to ignore the local configuration.
I use a custom core.sshcommand
configured at scope/origin global file:/root/.gitconfig
, but Go (on docker run golang:1.23-alpine3.20
, with apk add git
2.45.2) ignores the command I configured. I have to do GIT_SSH_COMMAND=$(git config core.sshcommand) go mod download
to workaround this.
What did you see happen?
$ docker run --rm -it golang:1.23.4-alpine3.20
/go # apk add git
fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/main/x86_64/APKINDEX.tar.gz
fetch https://dl-cdn.alpinelinux.org/alpine/v3.20/community/x86_64/APKINDEX.tar.gz
(1/12) Installing brotli-libs (1.1.0-r2)
(2/12) Installing c-ares (1.33.1-r0)
(3/12) Installing libunistring (1.2-r0)
(4/12) Installing libidn2 (2.3.7-r0)
(5/12) Installing nghttp2-libs (1.62.1-r0)
(6/12) Installing libpsl (0.21.5-r1)
(7/12) Installing zstd-libs (1.5.6-r0)
(8/12) Installing libcurl (8.11.1-r0)
(9/12) Installing libexpat (2.6.4-r0)
(10/12) Installing pcre2 (10.43-r0)
(11/12) Installing git (2.45.3-r0)
(12/12) Installing git-init-template (2.45.3-r0)
Executing busybox-1.36.1-r29.trigger
OK: 20 MiB in 27 packages
/go # cd /root
~ # git config --global core.sshcommand 'echo fail ssh && false'
~ # git config --global url."git@github.com:".insteadOf "https://github.com/"
~ # (echo 'package main'; echo 'import "github.com/nosuchrepo/nosuchrepo"'; echo 'func main() {}') >main.go
~ # (echo 'module example.com/xyz'; echo 'go 1.23'; echo 'require github.com/nosuchrepo/nosuchrepo v0.0.0') > go.mod
~ # go mod tidy # This unexpectedly uses the `ssh` command
go: downloading github.com/nosuchrepo/nosuchrepo v0.0.0
go: example.com/xyz imports
github.com/nosuchrepo/nosuchrepo: reading github.com/nosuchrepo/nosuchrepo/go.mod at revision v0.0.0: git ls-remote -q origin in /go/pkg/mod/cache/vcs/143f0bf38aa7670106f73ee5a75f1adb6d53f020b35c7e8b0dbf2c9d311f7766: exit status 128:
ssh -o ControlMaster=no -o BatchMode=yes: line 0: ssh: not found
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
~ # GIT_SSH_COMMAND=$(git config core.sshcommand) go mod tidy This uses the configured `core.sshcommand` as expected
go: downloading github.com/nosuchrepo/nosuchrepo v0.0.0
go: example.com/xyz imports
github.com/nosuchrepo/nosuchrepo: reading github.com/nosuchrepo/nosuchrepo/go.mod at revision v0.0.0: git ls-remote -q origin in /go/pkg/mod/cache/vcs/143f0bf38aa7670106f73ee5a75f1adb6d53f020b35c7e8b0dbf2c9d311f7766: exit status 128:
fatal: protocol error: bad line length character: fail
What did you expect to see?
The global gitconfig should be directly read by the Go command instead of separately configuring individual commands.
vt-ldragan
Metadata
Metadata
Assignees
Labels
GoCommandcmd/gocmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.