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: print useful reason when 'go mod tidy' and 'go get' fail due to missing git authentication credentials #31353

Open
Gurpartap opened this issue Apr 8, 2019 · 1 comment
Labels
help wanted modules NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@Gurpartap
Copy link

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

$ go version
go version devel +cb6646234c Fri Apr 5 20:54:50 2019 +0000 darwin/amd64

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/Gurpartap/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/Gurpartap/Projects/go"
GOPROXY=""
GORACE=""
GOROOT="/Users/Gurpartap/.gimme/versions/go"
GOTMPDIR=""
GOTOOLDIR="/Users/Gurpartap/.gimme/versions/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/ly/3f450xdn7g3bjzjdkh7y66tm0000gn/T/go-build674837816=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

$ mkdir fresh && cd fresh # outside $GOPATH
$ set -x -g GO111MODULE on
$ go mod init fresh
$ go get -v -x "google.golang.org/grpc"

What did you expect to see?

• If user was authenticated to pull from cloud.google.com:

The requested module to be downloaded and defined in go.mod. No problem.

• If user was not authenticated to pull from cloud.google.com:

This go get output needs to convey an actionable error reason for the user to fix the situation. Something like:

$ go get "google.golang.org/grpc"
go: finding cloud.google.com/go v0.26.0
go: google.golang.org/grpc@v1.19.1 ->
        cloud.google.com/go@v0.26.0: fatal: remote error: 

Invalid authentication credentials.

Please generate a new identifier:
  https://code.googlesource.com/new-password

What did you see instead?

This go get output does not convey any actionable error reason for the user to fix the situation.

$ go get "google.golang.org/grpc"
go: finding cloud.google.com/go v0.26.0
go: google.golang.org/grpc@v1.19.1 ->
        cloud.google.com/go@v0.26.0: unknown revision v0.26.0

I had to dig deeper with go get -v -x to find the command that failed. Thanks @thepudds and @heschik.

Then I had to manually execute the failing command (git ls-remote -q ...) to find the actual/useful failure reason.

go get -v -x "google.golang.org/grpc" Output
$ go get -v -x "google.golang.org/grpc"
Fetching https://google.golang.org/grpc?go-get=1
Parsing meta tags from https://google.golang.org/grpc?go-get=1 (status code 200)
get "google.golang.org/grpc": found meta tag get.metaImport{Prefix:"google.golang.org/grpc", VCS:"git", RepoRoot:"https://github.com/grpc/grpc-go"} at https://google.golang.org/grpc?go-get=1
mkdir -p /Users/Gurpartap/Projects/go/pkg/mod/cache/vcs # git2 https://github.com/grpc/grpc-go
# lock /Users/Gurpartap/Projects/go/pkg/mod/cache/vcs/53ab5f2f034ba42de32f909aa45670cf730847987f38664c4052b329152ad727.lock# /Users/Gurpartap/Projects/go/pkg/mod/cache/vcs/53ab5f2f034ba42de32f909aa45670cf730847987f38664c4052b329152ad727 for git2 https://github.com/grpc/grpc-go
cd /Users/Gurpartap/Projects/go/pkg/mod/cache/vcs/53ab5f2f034ba42de32f909aa45670cf730847987f38664c4052b329152ad727; git ls-remote -q https://github.com/grpc/grpc-go
6.443s # cd /Users/Gurpartap/Projects/go/pkg/mod/cache/vcs/53ab5f2f034ba42de32f909aa45670cf730847987f38664c4052b329152ad727; git ls-remote -q https://github.com/grpc/grpc-go
Fetching https://cloud.google.com/go?go-get=1
Parsing meta tags from https://cloud.google.com/go?go-get=1 (status code 200)
get "cloud.google.com/go": found meta tag get.metaImport{Prefix:"cloud.google.com/go", VCS:"git", RepoRoot:"https://code.googlesource.com/gocloud"} at https://cloud.google.com/go?go-get=1
mkdir -p /Users/Gurpartap/Projects/go/pkg/mod/cache/vcs # git2 https://code.googlesource.com/gocloud
# lock /Users/Gurpartap/Projects/go/pkg/mod/cache/vcs/b0e27935eb83c1d7843713bafab507e95768b550f0552cb42d9f41e5fd9c8375.lock# /Users/Gurpartap/Projects/go/pkg/mod/cache/vcs/b0e27935eb83c1d7843713bafab507e95768b550f0552cb42d9f41e5fd9c8375 for git2 https://code.googlesource.com/gocloud
go: finding cloud.google.com/go v0.26.0
cd /Users/Gurpartap/Projects/go/pkg/mod/cache/vcs/b0e27935eb83c1d7843713bafab507e95768b550f0552cb42d9f41e5fd9c8375; git tag -l
0.011s # cd /Users/Gurpartap/Projects/go/pkg/mod/cache/vcs/b0e27935eb83c1d7843713bafab507e95768b550f0552cb42d9f41e5fd9c8375; git tag -l
cd /Users/Gurpartap/Projects/go/pkg/mod/cache/vcs/b0e27935eb83c1d7843713bafab507e95768b550f0552cb42d9f41e5fd9c8375; git ls-remote -q https://code.googlesource.com/gocloud
1.439s # cd /Users/Gurpartap/Projects/go/pkg/mod/cache/vcs/b0e27935eb83c1d7843713bafab507e95768b550f0552cb42d9f41e5fd9c8375; git ls-remote -q https://code.googlesource.com/gocloud
go: google.golang.org/grpc@v1.19.1 ->
	cloud.google.com/go@v0.26.0: unknown revision v0.26.0
$ git ls-remote -q https://code.googlesource.com/gocloud

fatal: remote error: 

Invalid authentication credentials.

Please generate a new identifier:
  https://code.googlesource.com/new-password
@ALTree ALTree added modules NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. labels Apr 9, 2019
@ALTree ALTree added this to the Go1.13 milestone Apr 9, 2019
@bcmills
Copy link
Contributor

bcmills commented Apr 30, 2019

CC @jayconrod

@andybons andybons modified the milestones: Go1.13, Go1.14 Jul 8, 2019
@rsc rsc modified the milestones: Go1.14, Backlog Oct 9, 2019
@bcmills bcmills added help wanted NeedsFix The path to resolution is known, but the work has not been done. labels Oct 10, 2019
@gopherbot gopherbot removed the NeedsDecision Feedback is required from experts, contributors, and/or the community before a change can be made. label Oct 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted modules NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants