How to go mod download a private remote package in Github (error: “could not read Username”)

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 read a lot of issues about it (this Medium sums up soluces I’ve tried), but nothing works.

Any idea ? Many thanks !

2 Likes

Instead of rewriting to a URL containing credentials, you should use a git@ URL and provide a read only key on the build machine.

2 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.