Skip to content

Generated projects have no .copier-answers.yml, so copier update cannot bring template fixes into them #14

Closed

Description

@AlexeyShalaev

Versions: python-library-template 8ebf45d, Copier 9.18.2

There is no {{ _copier_conf.answers_file }}.jinja under template/ (_subdirectory: template, copier.yml:43). Without it, Copier writes no answers file, so a render records neither its answers nor the template commit it came from. copier update refuses to run, and the only way to get a template fix into an existing library is to copy it by hand. #8 (the ruff config) and #9 (docs.yml) are recent examples. None of the org's libraries has the file: I checked all 15 repos that have a publish.yml.

Reproduction

uvx --from copier==9.18.2 --with jinja2-time==0.2.0 copier copy --defaults --trust --vcs-ref 8ebf45d \
  --data project_name=demo-lib --data project_description="Demo library" \
  --data author_name="Bedrock Python" --data author_email=maintainers@example.com \
  gh:bedrock-python/python-library-template demo-lib
ls demo-lib/.copier-answers.yml
cd demo-lib && git init -q -b master && git add -A && git commit -qm init
uvx --from copier==9.18.2 --with jinja2-time==0.2.0 copier update --trust --defaults
for r in deadline-budget idempotency-kit omni-box clientwright; do
  gh api repos/bedrock-python/$r/contents/.copier-answers.yml --jq .path
done

Actual

ls: cannot access 'demo-lib/.copier-answers.yml': No such file or directory
Cannot update because cannot obtain old template references from `.copier-answers.yml`.
gh: Not Found (HTTP 404)
gh: Not Found (HTTP 404)
gh: Not Found (HTTP 404)
gh: Not Found (HTTP 404)

Why

#3 made this template the source of the org standard, and fixes keep landing here. Each fix then has to be redone by hand in every library, and nothing records which template commit a library was generated from, so there is no way to tell which fixes a library already has.

Proposal

Add template/{{_copier_conf.answers_file}}.jinja:

# Changes here will be overwritten by Copier; NEVER EDIT MANUALLY
{{ _copier_answers|to_nice_yaml -}}

I tried this on a local clone. The render then contains _commit, _src_path and the answers. After a template commit that raised the pytest floor, copier update --trust --defaults --vcs-ref HEAD in the render applied exactly that change (pyproject.toml | 2 +-, plus _commit in the answers file).

For the existing libraries, write the file by hand: _src_path: gh:bedrock-python/python-library-template, the answers, and as _commit the template commit each library was generated from (or the closest one). Then run copier update. The template has no tags, so copier update uses the default branch HEAD and versions it as 0.0.0.postN.devN+sha. Tagging template releases would make the jumps readable.

Activity

  1. AlexeyShalaev commented on Oct 16, 2026

    @AlexeyShalaev
    MemberAuthor

    Plan: add template/{{_copier_conf.answers_file}}.jinja as proposed. I considered other ways to record the source and found none: Copier reads the answers file and nothing else. I tried it with Copier 9.19.1. The render gets _commit, _src_path and the answers, and after a later template commit copier update --trust --defaults applied just that commit's change.

    Two more changes that become necessary once update works:

    • The post-generation _tasks message runs on copier update too and prints "Template generated. Next steps…" into a library that was set up long ago. It gets when: "{{ _copier_operation == 'copy' }}".
    • The template's CI renders, commits the render, and runs copier update in it. A template change that breaks update then fails the PR instead of the next library's update.

    The README gets a short "Pulling template changes into a library" section. Backfilling the answers file in the existing libraries is a per-library follow-up (_commit has to be the template commit each one is closest to), and I'm not making it here.

  2. added a commit that references this issue on Oct 16, 2026
    c508988
  3. AlexeyShalaev commented on Oct 16, 2026

    @AlexeyShalaev
    MemberAuthor

    The fix is in #21: the answers file, the post-generation message on copy only, and a CI job that updates a render of master to the PR commit and diffs it against a fresh render. The README section the PR adds covers backfilling the file in the existing libraries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions