xgo
xgo copied to clipboard
Issue installing private packages
Many thanks for extending the original xgo
package and introducing go mod
support.
I'm having an issue where private packages are not being installed on build. When trying to build, I get issues like this:
go: github.com/some_private_repo git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /go/pkg/mod/cache/vcs/...: exit status 128:
fatal: could not read Username for 'https://github.com': terminal prompts disabled
Running go get
works fine on the local machine since I have in the ~/.gitconfig
file:
[url "ssh://[email protected]/"]
insteadOf = https://github.com/
Any ideas?
Which CI server do you use? Perhaps it is possible to run git config...
to swap the git clone paths before running xgo (assuming you are running xgo inside the container instead of having xgo itself spin up container). For example the Gitea project runs custom commands in xgo container using drone to customize things before compile.
I wasn't using a CI server actually, I was just running xgo locally on my machine (i.e. having xgo spin up the container itself). Should I not be doing that?
Oh no, that's a totally acceptable usecase. Feel free to continue using this that way.
I wonder how we could achieve updating the git config inside the container. There are a few options off the top of my head, 1. use an env var to let container know to mount in git config 2. use an argument that takes git config info and runs that first. 3. something similar.
I think the above may also need to inject an SSH key in too (if we don't already) so that auth can be correct too. Perhaps mount the entire ~/.ssh directory as read only.
I think perhaps we may need to think about this more in depth, at least more than what I have above, as it likely affects gitlab (and other git forges such as Gitea), so having a generic way of doing whatever is planned is best.
I do the same as @vinceau, running xgo locally, and have run into the same challenge. One possible (though somewhat hamfisted) solution might be to allow go build -mod
flags to be passed into xgo? Such that xgo could be told to use the ./vendor
directory of the project for dependencies, presumably including private repos? Granted this means you have to locally vendor/cache everything..
Same problem, any hope on a solution? The -mod
flag would be fine by me, as our build is controlled via Makefile, so that's just a dependency to add.
Same problem here. The -mod
flag would be fine by me as well.
Is there any way to build a private ~~(or at least local)~~ repo? There doesn't seem to be a -mod
flag anymore
Edit: pointing to the local directory instead of module name works
What's the recommended way to build locally when there are dependencies in private repos?