sobjornstad / TiddlyRemember

Embed Anki notes in your TiddlyWiki
https://sobjornstad.github.io/TiddlyRemember/
MIT License
65 stars 7 forks source link

UnboundLocalError: local variable 'extra' referenced before assignment #59

Closed PayneGitHub closed 2 years ago

PayneGitHub commented 2 years ago

Hi,

Error message received when syncing Anki to a TiddlyStudy wiki:

`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, repeat 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 on the add-ons section of our support site. Debug info: Anki 2.1.49 (dc80804a) Python 3.8.1 Qt 5.15.1 PyQt 5.15.1 Platform: Linux Flags: frz=True ao=True sv=2 Add-ons, last update check: 2021-12-10 13:16:18 Add-ons possibly involved: ⁨TiddlyRemember⁩

Caught exception: Traceback (most recent call last): File "/home/user/.local/share/Anki2/addons21/60456529/twimport.py", line 71, in _invoke_tw_command proc = subprocess.run(cmd, cwd=wiki_path, stdout=subprocess.PIPE, File "subprocess.py", line 512, in run subprocess.CalledProcessError: Command '['tiddlywiki', '--verbose', '--output', '/tmp/tmpst82akfo/render', '--render', '[type[text/vnd.tiddlywiki]] [type[]] +[!is[system]]', '[encodeuricomponent[]addsuffix[.html]]', 'text/html', '$:/plugins/sobjornstad/TiddlyRemember/templates/TiddlyRememberParseable']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/user/.local/share/Anki2/addons21/60456529/importer.py", line 185, in join_thread if self.handle_thread_exception(): File "/home/user/.local/share/Anki2/addons21/60456529/importer.py", line 173, in handle_thread_exception raise exc File "/home/user/.local/share/Anki2/addons21/60456529/importer.py", line 57, in run self.notes = twimport.find_notes( File "/home/user/.local/share/Anki2/addons21/60456529/twimport.py", line 247, in find_notes _render_wiki(tw_binary, wiki_folder, renderlocation, filter) File "/home/user/.local/share/Anki2/addons21/60456529/twimport.py", line 175, in _render_wiki _invoke_tw_command(cmd, wiki_path, "render wiki") File "/home/user/.local/share/Anki2/addons21/60456529/twimport.py", line 86, in _invoke_tw_command f"Failed to {description}: return code {proc.returncode}.\n{extra}" UnboundLocalError: local variable 'extra' referenced before assignment`

Should extra variable superfluous?

Thanks.

sobjornstad commented 2 years ago

Yes, there's a mistake in the error handling code related to the extra variable, and I'll include a fix in the next version. But that isn't the cause of your issue – this code path only gets hit when there's already an unrecoverable error.

To get the full error output you need to figure out what's wrong, please edit /home/user/.local/share/Anki2/addons21/60456529/twimport.py and add just before line 85:

        else:
            extra = ""

Then follow the troubleshooting steps described at Exception during TiddlyRemember sync.

sobjornstad commented 2 years ago

The error-handling issue is fixed in the latest release, 1.3.2. If you haven't gotten around to investigating yet, you can update to that version instead of making the manual edit I discussed above.

PayneGitHub commented 2 years ago

Thank you Soren, Fix in latest version works perfectly.