Repository navigation
Go SDK issues with newer go.mod than packaged into engine #12349
Replies: 3 comments
|
Also gonna milestone this one, because this is a supreme pain (I spent a whole day tracking out what was really going on), at the very least we should have a nice error message for this. |
What's the failure? That In terms of handling this better, the fact that the go sdk is builtin to the engine is indeed a pretty big wrench here. We do that to avoid hard deps on the internet and to avoid problems in corp envs around need to use registry proxies. I can see some routes to do something like:
Which, if I understand the issue correctly, would probably be one possible reasonable next step. And in the long term I have some ideas on making it easier for users to customize what specifically gets builtin to the engine (or equivalent). This coincidentally overlaps quite a bit with what I was doing in #6714 today, I will think a bit more tomorrow and see what can be done for v0.10. |
|
Ahh, sorry, such a brain dump I didn't bother to write down the actual error. We get |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Writing up a brain dump, so might be a bit messy.
Currently the go version used by the Go SDK is
1.21.3. However, a user module can set a custom go version (usinggo.mod/go.work) to a higher version, like1.22.0.Now, this can cause fun issues it seems? I'm not quite sure what happens, but essentially in
dagger/cmd/codegen/generator/go/generator.go
Lines 292 to 302 in b2450fc
We can get a package returned that:
{ "ID": "foobar", "Name": "main", "PkgPath": "foobar", }for a
go.modthat looks like this:This silent failure is caused by https://github.com/golang/tools/blob/a821e617f30094a078bfdc1d63623b93365b3130/go/packages/packages.go#L1039 -
Checker.Files*can` return an error if we try and type-check for a go version that is greater than the currently installed version.This behavior makes sense (though the silent failure really doesn't). Note:
GOTOOLCHAIN=auto(as added in #6652 doesn't help for this, it only helps for compiling, not parsing+processing the package).However, this leaves us with the problem of how to manage this from the point-of-view of the Go SDK (cc @vito @sipsma). A few options:
codegenbinary itself if it asks for a different go version.x/toolsinternals.Open to other suggestions 🎉
Also see: https://github.com/golang/tools/blob/a821e617f30094a078bfdc1d63623b93365b3130/go/packages/packages.go#L930-L945
All reactions