-
-
Notifications
You must be signed in to change notification settings - Fork 173
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
Updating a project fails when Jinja extension with breaking change is used #1170
Comments
Hello! Yes, indeed this problem existed since forever. The lack of reproducibility inherent in many tools lead to this behavior. I experienced this same problem since years ago. 2020 prettiermaggeddon comes to my mind: prettier/prettier#9459. The problem was produced by the way pre-commit installed dependencies (no surprise) and the way prettier didn't care about it. Currently available on master, there's a new command: So, if you come to this situation, just recopy, solve conflicts, and move on. Luckily it's not so often. It's documented on master too: https://copier.readthedocs.io/en/latest/updating/#when-the-update-gets-broken-because-while-replaying-old-copy You can also provide an officially supported reproducible build of copier along with your template. See https://github.com/orgs/copier-org/discussions/1130#discussioncomment-5890503. |
The problem isn't related to lack of reproducibility in installing tools but to the way the update algorithm works. As Copier needs to re-generate a fresh project from the old template and generate a fresh project from the new template, two (fully deterministic) environments would be needed, but even with Nix, Docker or whatever, only one (fully deterministic) environment (typically the one for the new template) is available. For this, Copier would have to call Nix or Docker within the update process for generating those fresh projects. I don't think that's feasible. And without this, when the old and new version of a template rely on different versions of the same dependency with incompatible API, then it is simply impossible to perform an update. This is unrelated to deterministic installations. But if the update algorithm only had to generate a fresh project from the new template while a snapshot of a fresh project from the old template were retrieved from somewhere, this particular problem would be solved. I don't think |
Yes, indeed. Sorry for closing so fast! I didn't mean the issue is invalid. I just meant that you can hit the same basic problem (unable to replay) when the render process triggers some impure installation. But indeed you're right and this case can be really disconnected from that other one. It's also true that recopy isn't a replacement for update. What I meant is that it's a solution. Or a valid workaround. At the end of the day, I don't find myself hitting this problem very often. When that happens, a recopy just solves the problem and lets me continue updating from there onward. I actually found it when updating old templates with the current master, as it includes lots of breaking changes; and recopy helped a lot. If we stored a replay cache in hidden git refs as you suggest, we wouldn't need to replay (unless there's no such cache) and the problem would disappear (and copier would be faster on updates). However my point is: do we really need all that complexity, when a simple recopy unblocks the situation, and the problem is not extremely common? Let me reopen while we settle this. 😉 |
Another case in which updating a problem fails because the update algorithm replays the old template version is when Copier contains a breaking change such that the new template version works with the new Copier version but the old template version is incompatible. For instance, this might be a breaking change in |
Docs were a bit repetitive and unclear. Targets #1170. It could even fix it?
Well, this problem is inherent to the design and feature set of Copier, so I think it's time to settle wether it's just a known issue we can live with or there's something doable. Possible solutions:
To set thing clear, I don't have any willingness to implement any of the solutions because for me, number 1 just works and is good enough. Solutions 2 and 3 are clearly no-go. Among the others, what do you prefer? |
5 personally, but it's not perfect either. Cache gets deleted. Such a feature is a helper at best, sometimes users will have to fallback to recopy. So I wonder if it's worth it. |
6, probably unsurprisingly because I brought it up. I think we can make it optional, so that users who want to benefit from the reliable updating without replay need to push the Git ref. For those who don't want to do that, or for those who do but forgot to do it last time and lost the Git ref, Copier can fall back to replaying with the old template. This way, it's backwards compatible and less intrusive. Since I seem to be feeling this pain the most, I volunteer to work on a PR. Sounds okay, @yajo and @pawamoy? |
OK. I guess then that the reference to that cache (the remote, branch, tag, commit and/or whatever needed) should be stored along within the copier answers in something like |
I think Copier could use a custom refs namespace (like DVC), e.g. |
Docs were a bit repetitive and unclear. Targets #1170. It could even fix it? Co-authored-by: Timothée Mazzucotelli <pawamoy@pm.me> Co-authored-by: Sigurd Spieckermann <2206639+sisp@users.noreply.github.com>
Describe the problem
Consider the following situation:
So what's the problem? Copier's update algorithm re-generates a fresh project using the old version of the template (in this case, the one that uses v1 of the Jinja extension) and also generates a fresh project using the new version of the template (in this case, the one that uses v2 of the Jinja extension). But it is only possible to install one version of a package at a time in a virtual env, either v1 or v2 of the Jinja extension. So when v1 is installed, re-generating a fresh project using the old version of the template works but generating a fresh project using the new version of the template fails. And when v2 is installed, generating a fresh project using the new version of the template works but re-generating a fresh project using the old version of the template fails.
Template
See the next section for a complete test case.
To Reproduce
Add this test case to a new file, e.g.
tests/test_jinja_extension_breaking_change.py
, in Copier's test suite:Then, run
tests/test_jinja_extension_breaking_change.py
and observe that it fails.Logs
Expected behavior
The update process should succeed.
Screenshots/screencasts/logs
No response
Operating system
Linux
Operating system distribution and version
Ubuntu 22.04
Copier version
ff5aa05
Python version
CPython 3.10
Installation method
poetry+git
Additional context
I've come to think that re-generating a fresh project using the old version of the template is bad. Instead, the fresh project using the old version of the template should be saved and retrieved during the update process. I haven't figured out a concrete solution yet, but I wonder whether custom Git references might be useful (along the lines of https://iterative.ai/blog/experiment-refs). Perhaps custom Git refs could point to hidden commits, each of which contains a fresh project based on a specific version of a template. Then, those custom Git refs would be pushed as well and Copier's update algorithm could retrieve the fresh project from there instead of re-generating the project. But I haven't tried this out yet nor have I got experience with using custom Git refs. If anybody has a good idea, I'm all ears. 🙏
In fact, the problem isn't limited to Jinja extensions, but it's the most likely situation. Also, for example, a breaking change in the Jinja library itself might lead to this problem.
The text was updated successfully, but these errors were encountered: