go.sum not updated if local package is missing due to go generate #40834
Unanswered
tfaller
asked this question in
Request Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How are you running Renovate?
Self-hosted Renovate
Which platform you running Renovate on?
Gitea
Which version of Renovate are you using?
43.0.8
Please tell us more about your question or problem
The issue
If you generate code with
go generatee.g. for API endpoints from a spec file, you often don't commit these generated files into the repo. This can lead to "missing" packages. Renovate performs ago get -t ./...to update the go.sum file after changing the go.mod. The issue here is, that this command fails, because it can't find the local "missing" packages, becausego generatewas not run. Becausego getfails, the go.sum will never be updated -> the PR will just contain the go.mod. CI jobs will fail, because they need an updated go.sum.I see two possible solutions:
Option 1: Run go generate
The current existing option
goGenerateruns after vendoring. Not beforego get. Maybe run it also beforego getor introduce a second option for this.Option 2: Create the missing packages
We could simply create the missing packages beforehand. It is easy to identify these by running
go list ./.... Output like:It lists all existing and missing packages. If a missing package matches the module name in the go.mod we know it is a local one -> create a folder with a dummy
package.gofile, just containingpackage name. Also make sure we don't include these in the PR.Final thoughts
Instead of
go get -t ./...we could run it specifically with the modules that were updated in the go.mod. That would at least update the go.sum. But ifgoModTidyis enabled, it will not work -> it will also error out because of missing packages."Option 2" could be the safest play, because the
goGenerateoption is an "unsafe" one.We could also say: The user must themself create these dummy
package.gofiles and check them in. I see two issues with that:What do you think?
Logs (if relevant)
Logs
Beta Was this translation helpful? Give feedback.
All reactions