gregorias / anki-code-highlighter

Anki plugin for code syntax highlighting.
GNU Affero General Public License v3.0
59 stars 3 forks source link

Error on startup after install #36

Closed greggdonovan closed 1 year ago

greggdonovan commented 1 year ago

I got this error on Anki startup on MacOS after installing. The issue goes away after disabling the plugin. Any ideas? Thanks!

Error
An error occurred. Please start Anki while holding down the shift key, which will temporarily disable the add-ons you have installed.
If the issue only occurs when add-ons are enabled, please use the Tools > Add-ons menu item to disable some add-ons and restart Anki, repeating until you discover the add-on that is causing the problem.
When you've discovered the add-on that is causing the problem, please report the issue to the add-on author.
Debug info:
Anki 2.1.56 (07fd88dd) Python 3.9.15 Qt 6.3.2 PyQt 6.3.1
Platform: macOS-13.1-arm64-arm-64bit
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2023-02-02 19:08:00
Add-ons possibly involved: ⁨Highlight Code⁩

Caught exception:
Traceback (most recent call last):
  File "aqt.progress", line 118, in handler
  File "aqt.main", line 197, in on_window_init
  File "aqt.main", line 293, in setupProfile
  File "aqt.main", line 473, in loadProfile
  File "_aqt.hooks", line 3627, in __call__
  File "/Users/gdonovan/Library/Application Support/Anki2/addons21/112228974/main.py", line 417, in load_mw_and_sync
    sync_assets(
  File "/Users/gdonovan/Library/Application Support/Anki2/addons21/112228974/assets.py", line 210, in sync_assets
    asset_manager.delete_assets()
  File "/Users/gdonovan/Library/Application Support/Anki2/addons21/112228974/assets.py", line 103, in delete_assets
    self.modify_templates(lambda tmpl: delete_import_statements(
  File "/Users/gdonovan/Library/Application Support/Anki2/addons21/112228974/main.py", line 360, in transform_templates
    models.save(model)
  File "anki.models", line 559, in save
  File "anki.models", line 542, in update
  File "anki._backend_generated", line 883, in add_or_update_notetype
  File "anki._backend", line 151, in _run_command
anki.errors.CardTypeError: Card template ⁨1⁩ in notetype '⁨2. Mnemonics⁩' has a problem.<br>See the preview for more information.
gregorias commented 1 year ago

Thank you for reporting this.

Could you share with me your Anki collection, so that I can check myself what's going on with that notetype? I think just receiving the card templates should be enough to figure it out.

anki.errors.CardTypeError: Card template ⁨1⁩ in notetype '⁨2. Mnemonics⁩' has a problem.
See the preview for more information.

This error message is ambiguous, but the code message tells me it's probably that this plugin's modification mangles the template (source).

Notes to self:

greggdonovan commented 1 year ago

Thanks for the reply, @gregorias! It turns out I had a broken note type locally - it was a note type that used LaTeX, but I had no LaTeX installed (new laptop). Once I fixed that the problem went away... And thanks for the plugin, it's great!