-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
go.work without go.mod in workspace fails with failed to teardown GOPATH: unlinkat ...
#397
Comments
I'm interested to hear what your use-case is for using workspaces when you deploy your code. My understanding was that the workspaces feature was mostly to help out when you need to debug or patch dependencies locally, but that you'd switch to a replace directive when you really needed to deploy, maybe also pulling in a patched dependency once the change was in upstream. Can you provide some more context on why this works best for you? |
That's certainly one use-case, but deploying can be done to dev/staging environments as well. Are buildpacks not designed for local dev? I had planned to use Docker Compose to spin up multiple services locally, for higher fidelity and ease of lifecycle management.
IIUC using go.work and using replace-directives are orthogonal - you can use replace within a go.work file or directly in the go.mod file.
I have a mixed-language monorepo with some local modules, and some public. Git subtree is used to sync the public modules to repos as regular modules with their own go.mod files. That said, I don't expect anything different than what the go toolchain provides out of the box. Here's the rationale from the design doc. Monorepos are mentioned here. |
I'm running into this issue as well. I have services that import from other services (to get their gRPC service definition), a TL;DR: I need to pass multiple service directories into the docker build context in order for the build to work. The most straightforward way I've found (there may be options I've missed) is to mount the whole monorepo (though inefficient) into the context and build in a directory. |
A typical
go.work
setup (Go 1.18+ Workspaces) causes the build to fail in the teardown step, when running withBP_TARGETS="./sub"
.It appears the builder only checks for
go.mod
(and notgo.work
), so the builder assumes a pre-module (legacy) GOPATH app.Workaround
My deployment works by adding an empty wrapper
go.mod
in the project root:go mod init wrapper
This tricks the buildpack into assuming the (modern) go module build, which coincidentally fixes the build without breaking the
go build
command (in my case).Expected Behavior
Build should succeed.
Current Behavior
Possible Solution
Perhaps add a check for presence of
go.work
in the path manager.Steps to Reproduce
go.work
in app root:The
sub
directory contains the simple sample app (which has its owngo.mod
file, seesamples/go/mod
)Motivations
This took an unreasonable amount of time to track down, perhaps because I'm unused to buildpacks. I was deploying with fly.io and thought it was a problem on their end until I finally came down to the buildpack itself. Even then I wasn't sure if it was a permission error with my files. It would be helpful if the diagnostics could help differentiate between internal errors in the buildpack vs external errors (which I assume are much more common day-to-day).
Also, I still don't know how to test the fix locally. How can I do that?
The text was updated successfully, but these errors were encountered: