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: misleading error message with repeated folder name #51114

Closed
Deleplace opened this issue Feb 9, 2022 · 3 comments
Closed

cmd/go: misleading error message with repeated folder name #51114

Deleplace opened this issue Feb 9, 2022 · 3 comments
Assignees
Labels
FrozenDueToAge GoCommand cmd/go modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@Deleplace
Copy link
Contributor

Deleplace commented Feb 9, 2022

What version of Go are you using (go version)?

$ go version
go version go1.17.1 linux/amd64

Does this issue reproduce with the latest release?

Yes with 1.17.6

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
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=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.17.6"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/server/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1185892953=/tmp/go-build -gno-record-gcc-switches"

What did you do?

We have

  • a private repo at github.com/MyAccount/my-repo
    • containing a file server/go.mod starting with the line module github.com/MyAccount/my-repo/server
    • having the semver git tag server/v0.0.2
  • a distinct "client" project, having its own go.mod containing the lines
require (
	github.com/MyAccount/my-repo/server v0.0.2
)

Inside the "client" project, we launched

go build

(Sorry, can't give the full reproducible details of our private repo!)

What did you expect to see?

...
go: downloading github.com/MyAccount/my-repo/server v0.0.2
cmd/client/main.go:4:2: reading github.com/MyAccount/my-repo/server/go.mod at revision server/v0.0.2: git ls-remote -q origin in /go/pkg/mod/cache/vcs/f685fe342419a0c5eddd96688c386faf8f7622fa76c707a9c1c7c68bc353b5fe: exit status 128:
      Host key verification failed.
      fatal: Could not read from remote repository.

What did you see instead?

...
go: downloading github.com/MyAccount/my-repo/server v0.0.2
cmd/client/main.go:4:2: reading github.com/MyAccount/my-repo/server/server/go.mod at revision server/v0.0.2: git ls-remote -q origin in /go/pkg/mod/cache/vcs/f685fe342419a0c5eddd96688c386faf8f7622fa76c707a9c1c7c68bc353b5fe: exit status 128:
      Host key verification failed.
      fatal: Could not read from remote repository.

Note that the only unexpected bit is the repeated word at server/server.

This seems misleading: when seeing this error message, we thought that the "wrong" path github.com/MyAccount/my-repo/server/server/go.mod was the cause of the build failure. Did we make a mistake somewhere in the repo name/module name/package name/folder name?

We then realized that the root cause was only due to authentication difficulties with the go command using HTTPS or SSH to download the private repo.

After discussing this surprising error message with some Gophers, we now think the error message should not repeat the word "server" in the printed path.

@Deleplace
Copy link
Contributor Author

@rsc I'll see if I can pinpoint a relevant line in the code source.

If it helps, I may create sample repos to reproduce the error message (probably in a Docker container).

@seankhliao seankhliao added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 9, 2022
@Deleplace
Copy link
Contributor Author

The relevant method in go internals is (*codeRepo).findDir .

@bcmills bcmills self-assigned this Feb 11, 2022
@bcmills bcmills added this to the Go1.19 milestone Feb 11, 2022
@gopherbot
Copy link

Change https://go.dev/cl/386234 mentions this issue: cmd/go/internal/modfetch: avoid duplicating path components in Git fetch errors

@bcmills bcmills added the NeedsFix The path to resolution is known, but the work has not been done. label Feb 17, 2022
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Feb 17, 2022
jproberts pushed a commit to jproberts/go that referenced this issue Aug 10, 2022
…tch errors

Fixes golang#51114

Change-Id: Iebfe65f826b7b583ff2b48b8bc9d2eb23f2726af
Reviewed-on: https://go-review.googlesource.com/c/go/+/386234
Reviewed-by: Valentin Deleplace <deleplace@google.com>
Reviewed-by: Nooras Saba‎ <saba@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
@golang golang locked and limited conversation to collaborators Jul 14, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge GoCommand cmd/go modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
Development

No branches or pull requests

4 participants