cmd/go: private git repo shows "fatal: could not read Username: terminal prompts disabled"
Naatan opened this issue · 6 comments
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
go version go1.10.3 linux/amd64 vgo:2018-02-20.1
This is meaningless though as this number is exactly the same when doing a fresh vgo build from master, a bug in itself if you ask me.
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (go env)?
Arch Linux
GOARCH="amd64"
GOBIN="/home/nathanr/.go/bin"
GOCACHE="/home/nathanr/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/nathanr/.go"
GORACE=""
GOROOT="/usr/lib/go"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
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-build266124150=/tmp/go-build -gno-record-gcc-switches"
What did you do?
Ran go run foo.go on a file that relies on a package that is hosted by a private repository. I have full access to the private repository (git clone runs without prompts).
What did you expect to see?
Expected foo.go to run without issue
What did you see instead?
vgo: creating new go.mod: module github.com/foo
vgo: copying requirements from /home/nathanr/Downloads/cli/Gopkg.lock
vgo: converting /home/nathanr/Downloads/cli/Gopkg.lock: stat github.com/foo2@3202a6c2340e9f2a4d12488f713f775802f70b00: git fetch -f --depth=1 https://github.com/foo2 3202a6c2340e9f2a4d12488f713f775802f70b00 in /home/nathanr/.go/src/mod/cache/vcs/cf52c0b67175c259cd4f3aa0218158d0d841a412dbcb1a79c9d38349e3075c18: exit status 128:
fatal: could not read Username for 'https://github.com': terminal prompts disabled
Repo names anonymised
Additional Information
I found this relevant issue:
Tried building vgo with the fix included but no dice, error remains the same.
What vgo commit did you build from?
What happens if you attempt to go get the same repository with the ordinary go tool?
Are you using the credential helper?
git clone runs without prompts
Is that true for both HTTPS and SSH, or just one of the two?
I happened to encounter a similar error message. It turned out that it's a typo in my import path.
vgo: resolving import "github.com/PuerkitioBio/goquery"
vgo: import "github.com/PuerkitioBio/goquery": git ls-remote -q https://github.com/PuerkitioBio/goquery in /Users/mura/go/src/mod/cache/vcs/07f08583e403b0b6a20a20e9ad3cfc653e2cdb3124291642a1351c3b33c3a64
8: exit status 128:
fatal: could not read Username for 'https://github.com': terminal prompts disabled
~/w/mops ⑂ master + ⇡11 git ls-remote -q https://github.com/PuerkitioBio/goquery in /Users/mura/go/src/mod/cache/vcs/07f08583e403b0b6a20a20e9ad3cfc653e2cdb3124291642a1351c3b33c3a648
Username for 'https://github.com': typeless
Password for 'https://typeless@github.com':
remote: Repository not found.
Is that true for both HTTPS and SSH, or just one of the two?
Seems I had to run it with HTTPS. After I authed with HTTPS using git then I could run vgo without issue.
Imo the bug here is that vgo does not forward the prompt.
Edit: by the way even the workaround is not especially intuitive. One might argue "just auth using git and try again", but simply authenticating using git alone will not work around this issue. You first have to configure git to cache your credentials, only then can you first manually auth using git to work around the issue with vgo. Point being that if you know what to do it is relatively easily worked around, but it does not seem like a workflow you'd want to depend on with vgo.
This is not an issue in vgo but in cmd/go itself (if you run "go get" instead of "vgo get" you should see the same behavior). It's not a new bug either - we've turned off the terminal prompts for quite a few releases. It would be great to have better output here but I don't think it's critical for Go 1.11.
To reproduce:
$ HOME=/tmp go get github.com/rsc/nonexist
# cd .; git clone https://github.com/rsc/nonexist /Users/rsc/src/github.com/rsc/nonexist
Cloning into '/Users/rsc/src/github.com/rsc/nonexist'...
fatal: could not read Username for 'https://github.com': terminal prompts disabled
package github.com/rsc/nonexist: exit status 128
$