buildpacks
buildpacks copied to clipboard
Setting GOPRIVATE does not find Private Modules
How should the GOPRIVATE
env var be set while running pack
, version 0.10.0
? I get the following error message:
[builder] Running "go build -ldflags -s -w -o /layers/google.go.build/bin/main ./cmd/inviteapp (GOCACHE=/layers/google.go.build/gocache)"
[builder] go: github.com/myorg/[email protected]: reading github.com/myorg/mymod/go.mod at revision v0.0.1: unknown revision v0.0.1
[builder] Done "go build -ldflags -s -w -o /layers/google.go.build/bin/main ..." (744.836487ms)
[builder] Failure: go: github.com/myorg/[email protected]: reading github.com/myorg/mymod/go.mod at revision v0.0.1: unknown revision v0.0.1
Below are the commands I am using to create the image
pack build myapp:dev --verbose --builder=gcr.io/buildpacks/builder --env GOOGLE_BUILDABLE="./cmd/myapp" --env GOOGLE_GOLDFLAGS="-s -w" --env GOPRIVATE="github.com/myorg/*"
On my host the flags work, but I understand that pack
command does not read from the environment. I can confirm I am able to read the module information when adding the go-get=1
query parameter to the specific private package after setting the GOPRIVATE
variable.
Thank you all for your time!
Thank you for filing the issue. Pack does not provide access to the git credentials that you have stored locally, so private dependencies will be inaccessible by Go. Unfortunately we don't have a good answer for this, yet. As a workaround, you could try vendoring your private dependencies as described here (the docs mention App Engine, but the same process should work here as well).
Thanks @lukasberger for taking a look at this. I am excited to see the direction the tool takes. If the team would consider including the fact that private modules are not yet supported bas one of the caveats, that would be great for folks coming to the project.