Go: Error: go mod download a private remote package in Github ( “could not read Username”)

Created on 10 Sep 2019  Â·  8Comments  Â·  Source: golang/go

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

$ go version go1.12.9 darwin/amd64

Does this issue reproduce with the latest release?

I didn't try it

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

Output

$ GOARCH="amd64"
GOBIN=""
GOCACHE="{redacted}/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/{redacted}/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.12.9/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.12.9/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/{redacted}/{redacted}/{redacted}/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/83/wlwj_kj92wvfscsx4vrm19090gkgk5/T/go-build718486207=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I'm trying to access a Go private remote package on my firm's Github inside a CircleCI's job. I've managed to get it in the test job, with:

git config --global url."https://{user}:${token}@github.com/".insteadOf "https://github.com/"

But somehow, this command doesn't work in the build job. I have this error at the Build app Docker image step, when "RUN go mod download" is launched :

fatal: could not read Username for 'https://github.com': terminal prompts disabled

I've tried :

  • git config --global url."https://{user}:${GITHUB_TOKEN}@github.com/".insteadOf "https://github.com/": works locally, in test job on CI but not in build job
  • git config --global url."https://${GITHUB_TOKEN}:[email protected]/".insteadOf "https://github.com/"
  • echo "machine github.com login xxxx password xxx">~/.netrc
  • git config --global url.ssh://[email protected]/.insteadOf https://github.com/

Any idea ? Many thanks !

(Warning: I'm a junior dev, beginning to work with Go; sorry if it's dumb)

What did you expect to see?

No errors.

What did you see instead?

fatal: could not read Username for 'https://github.com': terminal prompts disabled

All 8 comments

If it's related to docker, try running:
RUN echo "[url \"[email protected]:\"]\n\tinsteadOf = https://github.com/" >> /root/.gitconfig with your user and token provided.

Have you tried export GIT_TERMINAL_PROMPT=1 before issuing your command?

Have you tried export GIT_TERMINAL_PROMPT=1 before issuing your command?

@helgix yes, and I have now this error :

fatal: could not read Username for 'https://github.com': No such device or address

This issue seems to be a question about how to use Go, rather than a feature request or defect report about the Go language and/or toolchain.

We have decided that our experiment to allow questions on the issue tracker has not had the outcome we desired, so I am closing this issue. I'm sorry that we can't answer your question here.

There are many other methods to get help if you're still looking for answers:

Thanks

@arturasjurev yes, and I have this error now :
ssh -o ControlMaster=no: line 1: ssh: not found fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
I'm guessing I have to add a .ssh during my build then ?

@bcmills thank you, I understand.

If someone has an idea, don't hesitate to go on :

Thanks again

@bcmills thank you, I understand.

If someone has an idea, don't hesitate to go on :

Thanks again

Hi @FradiFrad got 404 page not found

@adzimzf it looks like the stack overflow question has been removed. Unlike many projects on GitHub, the Go project does not use its bug tracker for general discussion or asking questions. We only use our bug tracker for tracking bugs and tracking proposals going through the Proposal Process.

Please see https://golang.org/wiki/Questions for good places to ask questions.

Was this page helpful?
0 / 5 - 0 ratings