getnikola / nikola

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

Post-Upgrade bugs #3571

Open nickvence opened 2 years ago

nickvence commented 2 years ago

Environment

Python Version: 3.9.6

Nikola Version: 8.1.3

Operating System: macOS 10.14.6

Description:

After breaking ghp-import and unsuccessfully trying to reinstall it, I reinstalled an updated version of nikola 8.1.3 this time in a virtual environment.

Since then I have two (possibly related) bugs.

❯ nikola build Scanning posts........done! . render_sidebar:output/sidebar-en.inc TaskError - taskid:render_sidebar:output/sidebar-en.inc PythonAction Error Traceback (most recent call last): File "/Users/nvence/virtualenvs/nikola/lib/python3.9/site-packages/doit/action.py", line 437, in execute returned_value = self.py_callable(self.args, kwargs) File "/Users/nvence/virtualenvs/nikola/lib/python3.9/site-packages/nikola/nikola.py", line 1472, in render_template data = self.template_system.render_template( File "/Users/nvence/virtualenvs/nikola/lib/python3.9/site-packages/nikola/plugins/template/mako.py", line 113, in render_template data = template.render_unicode(context) File "/Users/nvence/virtualenvs/nikola/lib/python3.9/site-packages/mako/template.py", line 478, in render_unicode return runtime._render( File "/Users/nvence/virtualenvs/nikola/lib/python3.9/site-packages/mako/runtime.py", line 878, in _render _render_context( File "/Users/nvence/virtualenvs/nikola/lib/python3.9/site-packages/mako/runtime.py", line 920, in _render_context _exec_template(inherit, lclcontext, args=args, kwargs=kwargs) File "/Users/nvence/virtualenvs/nikola/lib/python3.9/site-packages/mako/runtime.py", line 947, in _exectemplate callable(context, args, **kwargs) File "/Users/nvence/site/cache/.mako.tmp/sidebar.tmpl.py", line 40, in render_body M_writer(str( helper.list_posts(global_posts) )) File "/Users/nvence/site/cache/.mako.tmp/sidebar-helper.tmpl.py", line 37, in render_list_posts __M_writer(str( messages("Recent Posts", lang) )) File "/Users/nvence/virtualenvs/nikola/lib/python3.9/site-packages/nikola/utils.py", line 216, in call__ return self[lang][key] KeyError: 'Recent Posts'

######################################## render_sidebar:output/sidebar-en.inc :

Thank you for your help, I am really at a loss on what to do.

Kwpolska commented 2 years ago

Regarding the nikola build issue — it sounds really strange. Can you try the following sequence of commands?

nikola build
nikola dumpdb > one.log
vim whatever.rst  # (or use your favorite editor to edit the file in a visible way)
nikola build
nikola dumpdb > two.log

If you can still reproduce (i.e. the change is not reflected after the second nikola build), please attach one.log and two.log produced by these commands.

Regarding sidebar — please consult the plugin’s README file. You need to make some changes to the messages files in your site to make this plugin work.

nickvence commented 2 years ago

Here is the results:

❯ nikola build
Scanning posts........done!
.  render_posts:timeline_changes
.  render_posts:cache/pages/research.html
.  render_sidebar:output/sidebar-en.inc
TaskError - taskid:render_sidebar:output/sidebar-en.inc
PythonAction Error
Traceback (most recent call last):
  File "/Users/nvence/virtualenvs/nikola/lib/python3.9/site-packages/doit/action.py", line 437, in execute
    returned_value = self.py_callable(*self.args, **kwargs)
  File "/Users/nvence/virtualenvs/nikola/lib/python3.9/site-packages/nikola/nikola.py", line 1472, in render_template
    data = self.template_system.render_template(
  File "/Users/nvence/virtualenvs/nikola/lib/python3.9/site-packages/nikola/plugins/template/mako.py", line 113, in render_template
    data = template.render_unicode(**context)
  File "/Users/nvence/virtualenvs/nikola/lib/python3.9/site-packages/mako/template.py", line 478, in render_unicode
    return runtime._render(
  File "/Users/nvence/virtualenvs/nikola/lib/python3.9/site-packages/mako/runtime.py", line 878, in _render
    _render_context(
  File "/Users/nvence/virtualenvs/nikola/lib/python3.9/site-packages/mako/runtime.py", line 920, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/Users/nvence/virtualenvs/nikola/lib/python3.9/site-packages/mako/runtime.py", line 947, in _exec_template
    callable_(context, *args, **kwargs)
  File "/Users/nvence/site/cache/.mako.tmp/sidebar.tmpl.py", line 40, in render_body
    __M_writer(str( helper.list_posts(global_posts) ))
  File "/Users/nvence/site/cache/.mako.tmp/sidebar-helper.tmpl.py", line 37, in render_list_posts
    __M_writer(str( messages("Recent Posts", lang) ))
  File "/Users/nvence/virtualenvs/nikola/lib/python3.9/site-packages/nikola/utils.py", line 216, in __call__
    return self[lang][key]
KeyError: 'Recent Posts'

########################################
render_sidebar:output/sidebar-en.inc <stdout>:

❯ nikola dumpdb > one.log
ERROR: ndbm does not support iteration of elements
Kwpolska commented 2 years ago

There are two things visible in this log:

  1. sidebar locale misconfiguration — please fix this first (edit your messages file to include the messages expected by the sidebar plugin
  2. dumpdb not working with your specific database type

As an alternative, after fixing the sidebar issue, I'd suggest the following way of getting the database between runs:

rm .doit.db
nikola build --backend=json
cp .doit.db one.json
vim whatever.rst  # (or use your favorite editor to edit the file in a visible way)
nikola build --backend=json
mv .doit.db two.json
nickvence commented 2 years ago

Chris, I really appreciate your time, I’ve been interviewing for a new job and I feel bad for not having had the energy to get back to you sooner.

  1. TL;DNR I uninstalled the sidebar plugin and turned my sidebar-directive into a note-directive to temporarily get things working again.

Upon upgrading to Nikola 8.1.3 (from 8.1.2) and installing it in a virtual environment, my sidebar-directives (.. sidebar::) stopped working. I thought the sidebar-directive was like a float version of the note-directive. In my debugging efforts, I installed the sidebar plugin (I don’t remember doing this under 8.1.2), but this only spawned a new (and complex) stream of errors. After some sleuthing, I have decided that the sidebar-directive is different from the sidebar-plugin (an HTML-sidebar having a table-of-contents-like structure). I have temporarily renamed sidebar directives as notes for debugging purposes.

  1. FYI .doit.db was named .doit.db.db After removing it, the website now builds. Here is the results of nikola build —backend=json cp .doit.db one.json

vim posts/comparing-distributions.rst nikola build —backend=json

Good news: nothing is broken Bad news: .. sidebar:: doesn’t render on the side

I’m hoping for the functionality of the Magic Links sidebar on https://getnikola.com/handbook.html or https://nickvence.github.io/posts/comparing-distributions.html

Thanks, Nick

Kwpolska commented 2 years ago

The sidebar directive is separate from the sidebar plugin. In a clean site, the .. sidebar directive shows up on the side, but it’s theme-dependent. What theme are you using?