xcaddy: xcaddy does not download newly published module versions, even when specified
I published a new version of my module by tagging it and pushing the tag to GH, and immediately tried to xcaddy build with it like xcaddy build --with github.com/infogulch/my-module@v0.0.2, but xcaddy continued to use the old module version. After I manually updated the go proxy service with go get github.com/infogulch/my-module@v0.0.2 then it pulled in the new version. (See https://proxy.golang.org/#faq-new-version)
Some issues:
- I would expect
xcaddy build --with module@versionto download new module versions likego get module@versiondoes. - I would expect xcaddy to complain and fail to build if it didn’t find the version I specify, instead of just building with whatever other version it happens to find instead.
I expect this to reproduce with the following steps:
- Create a new module and publish a version
- Create new repo containing a caddy module
- Tag an initial version
git tag -a v0.0.1; git push --tags - Add it to the proxy
go get my-module@v0.0.1 - Verify that it builds in caddy
xcaddy build --with my-module@v0.0.1
- Publish a new version
git commit ...; git tag -a v0.0.2; git push --tags- Do not manually fetch it with
go get - Try to xcaddy build with the new version
xcaddy build --with my-module@v0.0.2 - Observe in the build logs that it is still using
v0.0.1
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 18 (10 by maintainers)
Commits related to this issue
- try @infogulch repl override — committed to Jesssullivan/xcaddy by Jesssullivan 2 years ago
- bugfix- #221, xcaddy skips minor updates of lexical submodules (#238) * try @infogulch repl override * Update environment.go * Add notes regarding intended module iteration behavior, ignore JB dotf... — committed to caddyserver/xcaddy by Jesssullivan 2 years ago
🤔 I’ve been fiddling around with this today, locally this seems to have gotten me on the right track. Fingers crossed, maybe a PR later this evening 🐱
I figured the culprit line. Here xcaddy loops over all plugins/dependencies to execute
go getagainst them:https://github.com/caddyserver/xcaddy/blob/33391103931bd395b98c11e6cf7af8e9b95f90e7/environment.go#L181-L196
Critically, in this segment xcaddy skips replaced modules by checking if the package path of this iteration is prefixed by a package path that is replaced, i.e. if the current package path is
github.com/infogulch/xtemplate-caddyand the replaced package isgithub.com/infogulch/xtemplate, then … oopshttps://github.com/caddyserver/xcaddy/blob/33391103931bd395b98c11e6cf7af8e9b95f90e7/environment.go#L183-L191
The assumption made during the write of the tool is written in the comment. Our assumption is apparently not optimal. I don’t have an immediate solution from the top of my head right now. If you (or any passerby) figures it out, feel free to share.
I can think of a few ugly workarounds…
This is strange because xcaddy isn’t doing anything special. It’s a wrapper around
gocommand, and it does callgo getwith the module path and version:https://github.com/caddyserver/xcaddy/blob/eb894be6a004097e5ef67db4d8bcdb579d8ae1b8/environment.go#L182-L193
xcaddy cannot know to fail or complain if the
go getcommand itself succeeds. I wonder if it’s local build cache issue… but it’s a clean env 🤔Ah, haha thanks Mohammed. We might be better off checking for prefix match plus “/” or EOS. I’ve done this a few times before but this code was written before I was so wise 🙃
Oh, ok, I see it now. When you had the local override, the next module was skipped for some reason. I’m thinking this is an unintentional bug, one of those infamous off-by-one error. Let’s check it.
Thanks; from the logs:
That’s weird. It then downloads caddy/v2, but it shouldn’t be getting v1 at all… I would check your plugins for correctness here…
Mohammed is right though; xcaddy literally just wraps the
gocommand, so I’m not sure if we’re the best situated to troubleshoot this. I’m not really sure what’s going on. 🤷♂(Closing, since I don’t think there’s anything we can fix in xcaddy for this, but feel free to continue discussion!)