getnikola / nikola

A static website and blog generator
https://getnikola.com/
MIT License
2.62k stars 450 forks source link

jinja2.exceptions.TemplateNotFound: annotation_helper.tmpl #3774

Closed oraNod closed 6 months ago

oraNod commented 6 months ago

Environment

Python Version:

$ python --version Python 3.12.3

Nikola Version:

$ nikola --version Nikola v8.3.1

Operating System:

$ cat /etc/fedora-release Fedora release 39 (Thirty Nine)

Description:

Nikola builds fail due to missing annotation_helper.tmpl. Seems to relate to #3764 and #3765

We use a custom jinja theme based on bootstrap4-jinja. Here is the exception that we've encountered:

nikola build --strict
[2024-05-13 08:51:51] INFO: Nikola: Running in strict mode
[2024-05-13 08:51:52] ERROR: Nikola: Error loading tasks. An unhandled exception occurred.
Traceback (most recent call last):
  File "/home/runner/work/community-website/community-website/.nox/build/lib/python3.11/site-packages/nikola/__main__.py", line 285, in load_tasks
    tasks = generate_tasks(
            ^^^^^^^^^^^^^^^
  File "/home/runner/work/community-website/community-website/.nox/build/lib/python3.11/site-packages/doit/loader.py", line 390, in generate_tasks
    for task_dict, x_doc in flat_generator(gen_result, gen_doc):
  File "/home/runner/work/community-website/community-website/.nox/build/lib/python3.11/site-packages/doit/loader.py", line 27, in flat_generator
    for item in gen:
  File "/home/runner/work/community-website/community-website/.nox/build/lib/python3.11/site-packages/nikola/nikola.py", line 2069, in gen_tasks
    for task in flatten(pluginInfo.plugin_object.gen_tasks()):
  File "/home/runner/work/community-website/community-website/.nox/build/lib/python3.11/site-packages/nikola/nikola.py", line 2063, in flatten
    for t in task:
  File "/home/runner/work/community-website/community-website/.nox/build/lib/python3.11/site-packages/nikola/plugins/task/listings.py", line 183, in gen_tasks
    template_deps = self.site.template_system.template_deps('listing.tmpl', self.site.GLOBAL_CONTEXT)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/community-website/community-website/.nox/build/lib/python3.11/site-packages/nikola/plugins/template/jinja.py", line 137, in template_deps
    self.dependency_cache[template_name] = [filename] + self.get_deps(filename, context)
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/community-website/community-website/.nox/build/lib/python3.11/site-packages/nikola/plugins/template/jinja.py", line 131, in get_deps
    return self.get_string_deps(text, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/community-website/community-website/.nox/build/lib/python3.11/site-packages/nikola/plugins/template/jinja.py", line 122, in get_string_deps
    sub_deps = [filename] + self.get_deps(filename, context)
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/community-website/community-website/.nox/build/lib/python3.11/site-packages/nikola/plugins/template/jinja.py", line 131, in get_deps
    return self.get_string_deps(text, context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/community-website/community-website/.nox/build/lib/python3.11/site-packages/nikola/plugins/template/jinja.py", line 121, in get_string_deps
    filename = self.lookup.loader.get_source(self.lookup, dep_name)[1]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/community-website/community-website/.nox/build/lib/python3.11/site-packages/jinja2/loaders.py", line 204, in get_source
    raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: annotation_helper.tmpl

https://github.com/ansible-community/community-website/actions/runs/8963240868/job/24888849506?pr=455#step:4:50

Creating the file with touch templates/annotation_helper.tmpl seems to fix things and the build then succeeds.

oraNod commented 6 months ago

@felixfontein FYI :smile_cat:

evgeni commented 6 months ago

"fixed" in https://github.com/getnikola/nikola/commit/ccf74ad60c8788bc234075936c6e5d37806a6b25

but your theme should be updated to not reference that file anymore :)

(also, :wave: @oraNod)

oraNod commented 6 months ago

Thanks @evgeni :wave:

I saw that commit but failed to catch the reference to annotation_helper in the base.tmpl file in our theme. I'll close this now. Thanks! And apologies for the noise.

felixfontein commented 6 months ago

It's great to see you solved this without me ;) Thanks! :)