sobjornstad/TiddlyRemember

OSError: [WinError 145] The directory is not empty

Opened this issue · 12 comments

Hey,

I get this error when attempting to sync.

Debug info:
Anki 2.1.38 (355e4cd5) Python 3.8.6 Qt 5.14.2 PyQt 5.14.2
Platform: Windows 10
Flags: frz=True ao=True sv=1
Add-ons, last update check: 2021-04-23 12:06:35

Caught exception:
Traceback (most recent call last):
  File "C:\Users\yaren\AppData\Roaming\Anki2\addons21\60456529\__init__.py", line 187, in join_thread
    if self.handle_thread_exception():
  File "C:\Users\yaren\AppData\Roaming\Anki2\addons21\60456529\__init__.py", line 175, in handle_thread_exception
    raise exc
  File "C:\Users\yaren\AppData\Roaming\Anki2\addons21\60456529\__init__.py", line 62, in run
    self.notes = twimport.find_notes(
  File "C:\Users\yaren\AppData\Roaming\Anki2\addons21\60456529\twimport.py", line 202, in find_notes
    notes = _notes_from_paths(
  File "tempfile.py", line 827, in __exit__
  File "tempfile.py", line 831, in cleanup
  File "tempfile.py", line 813, in _rmtree
  File "shutil.py", line 737, in rmtree
  File "shutil.py", line 610, in _rmtree_unsafe
  File "shutil.py", line 610, in _rmtree_unsafe
  File "shutil.py", line 619, in _rmtree_unsafe
  File "shutil.py", line 617, in _rmtree_unsafe
OSError: [WinError 145] The directory is not empty: 'C:\\Users\\yaren\\AppData\\Local\\Temp\\tmp6a1eapcz\\wikifolder\\tiddlers'

I've attempted to remove the temporary folder & re-run, but the issue remains.

image

I've tried moving the wiki to a different different directory (like download) but no luck.

Thanks 😇

I had one other person report this recently, but unfortunately we never got to the bottom of it. I'm pretty sure it is not a TiddlyRemember bug, but something goofy with Windows, which is terrible about file locking, but it's possible there's something I could do to work around it if we can figure out what the problem is.

Can you make sure that you have the latest version of both Anki and TiddlyRemember?

This could be a permissions issue with your temp folder, which is something that's happened with Anki occasionally -- check out https://docs.ankiweb.net/#/files?id=permissions-of-temp-folder and see if that helps at all.

@danielyaren Were you able to figure this out? I'd like to have something for the next person if so. :-)

Unfortunately no, I didn't find a solution.

Following #52 (comment).

I tried to reboot, but unfortunately it didn't help. The error stays the same:

Error
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 on the add-on support site.
Debug info:
Anki 2.1.49 (dc80804a) Python 3.8.6 Qt 5.14.2 PyQt 5.14.2
Platform: Windows 10
Flags: frz=True ao=True sv=2
Add-ons, last update check: 2021-12-04 10:08:24

Caught exception:
Traceback (most recent call last):
  File "C:\Users\roman.vesely\AppData\Roaming\Anki2\addons21\60456529\importer.py", line 185, in join_thread
    if self.handle_thread_exception():
  File "C:\Users\roman.vesely\AppData\Roaming\Anki2\addons21\60456529\importer.py", line 173, in handle_thread_exception
    raise exc
  File "C:\Users\roman.vesely\AppData\Roaming\Anki2\addons21\60456529\importer.py", line 57, in run
    self.notes = twimport.find_notes(
  File "C:\Users\roman.vesely\AppData\Roaming\Anki2\addons21\60456529\twimport.py", line 248, in find_notes
    notes = _notes_from_paths(
  File "tempfile.py", line 827, in __exit__
  File "tempfile.py", line 831, in cleanup
  File "tempfile.py", line 813, in _rmtree
  File "shutil.py", line 737, in rmtree
  File "shutil.py", line 610, in _rmtree_unsafe
  File "shutil.py", line 610, in _rmtree_unsafe
  File "shutil.py", line 619, in _rmtree_unsafe
  File "shutil.py", line 617, in _rmtree_unsafe
OSError: [WinError 145] The directory is not empty: 'C:\\Users\\ROMAN~1.VES\\AppData\\Local\\Temp\\tmpwcnqo6_1\\wikifolder\\tiddlers'

I have all TiddlyWiki, TiddlyRemember and Anki (reinstalled from scratch) in the last versions. Tried as well on clean TiddlyWiki + TiddlyRemember. Unfortunately, I don't know whether new versions caused this as I did not tried to sync since previous versions and had some OS updates in the meantime.

OK, now I've managed it to work! Here's what I did:

  1. removed all files inside AppData\Local\Temp directory (in the end I think this is not really needed...)
  2. inside Anki run Sync from TiddlyWiki; the directory with the name on the last line displayed in the error was created in Temp (i.e. tmpwcnqo6_1 in my previous comment)
  3. checked files inside tmpwcnqo6_1\wikifolder\tiddlers; all were tiddler source files with similar content:
created: 20211127212435557
modified: 20211127212438651
title: $:/state/add-plugin-info/$:/temp/ServerConnection/https://tiddlywiki.com/library/v5.2.0/index.html/$:/temp/RemoteAssetInfo/https://tiddlywiki.com/library/v5.2.0/index.html/$:/plugins/tiddlywiki/github-fork-ribbon

no
  1. searched for all of them in my TiddlyWiki and deleted them
  2. sync is now working!

I have not idea why those files could caused this kind of error, but hopefully it helps.

I bet the issue is that the title of this tiddler, and thus the URL-encoded filename, is so long that Windows didn't want to accept the delete request when TiddlyRemember tried to clean up after itself (in theory, of course, it also wouldn't have been able to create this file initially, but most likely Node.js makes the creation request in a way that functions differently, while it's Python trying to request the deletion).

I'll look into whether something can be done to detect and work around this. Thanks for the report!

I also experienced this, my internet went down while I was looking at a plugin library. It resulted in these tiddlers
image
like with the above everything was fixed after removing them.

Oh also like mentioned they all said no, the ones that stated yes but had similar names did not result in an issue.

Oh also like mentioned they all said no, the ones that stated yes but had similar names did not result in an issue.

@GameDungeon, do you happen to have the names of the ones that said yes? If it's true that the content has an impact, then my hypothesis about this issue is completely wrong. I'm guessing it's just that they happened to have slightly shorter names, enough to make the difference, but it would be good to know for sure.

Ah wait no, I thought that was the case, but no, there are some yes-es in there too. ( the long names in the search had confused me )

image

( interestingly I have a version containing the bugged tiddlers through the sheer luck of me moving it in a USB while it was broken. Notably, all the backups did not contain these bugged tiddlers. )

From #65: We could also see if there's a different way to pick a filename for the exported tiddlers -- the new slugify[] operator comes to mind but doesn't guarantee uniqueness.

Would a short hash work? I guess hashes aren't known for their shortness....

It would work great, but it has to be a TiddlyWiki filter and I don't think there is a hash filter operator.