Aleks-Ya / fastwordquery-3

A fork of Fast Word Query with support for DWDS and BAmooz dictionaries
Apache License 2.0
4 stars 1 forks source link

Read-only file system: '_fastwqcfg.json' #1

Closed SOREMUZ closed 8 months ago

SOREMUZ commented 8 months ago

Hi Aleksey,thank you for updating this addon,but when I opened it some errors popped up

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 23.10 (51a10f09) Python 3.9.15 Qt 6.5.3 PyQt 6.5.3 Platform: macOS-13.2.1-arm64-arm-64bit Flags: frz=True ao=True sv=3 Add-ons, last update check: 2023-11-05 22:47:12 Add-ons possibly involved: ⁨Fast Word Query 3⁩

Caught exception: Traceback (most recent call last): File "/Users/chikane/Library/Application Support/Anki2/addons21/1956435337/gui/options.py", line 182, in _after_build self.build_tabs_layout() File "/Users/chikane/Library/Application Support/Anki2/addons21/1956435337/gui/options.py", line 248, in build_tabs_layout self.save() File "/Users/chikane/Library/Application Support/Anki2/addons21/1956435337/gui/options.py", line 318, in save config.update(data) File "/Users/chikane/Library/Application Support/Anki2/addons21/1956435337/context.py", line 60, in update with open(self.path, 'w', encoding='utf-8') as f: OSError: [Errno 30] Read-only file system: '_fastwqcfg.json'

Aleks-Ya commented 8 months ago

Hi @SOREMUZ , Thanks for reporting

This error happens if Anki can't write "Fast Word Query" config file (_fastwqcfg.json) into the user's home directory. I guess it will be /Users/chikane/_fastwqcfg.json on your machine. This is related to filesystem configuration of your machine. To simplify your investigation I added full path to log and to error message. E.g. 2023-11-07 00:20:20,422 Config update DEBUG Update file: /home/aleks/_fastwqcfg.json.

Try to update the add-on, find exact path to the config file and check why this file is read-only.

Logs location on your machine: /Users/chikane/Library/Application Support/Anki2/addons21/1956435337/fastwordquery-3.log

Please, let me know about the results.

SOREMUZ commented 8 months ago

Hi Aleksey,here is the log file

2023-11-07 12:53:51,651 root INFO Logger is configured: file=/Users/chikane/Library/Application Support/Anki2/addons21/1956435337/fastwordquery-3.log 2023-11-07 12:53:51,965 Config read DEBUG Reading file: /.fastwqcfg.json 2023-11-07 12:53:51,965 Config read ERROR can not find config file Traceback (most recent call last): File "/Users/chikane/Library/Application Support/Anki2/addons21/1956435337/context.py", line 79, in read with open(full_path, 'r', encoding="utf-8") as f: FileNotFoundError: [Errno 2] No such file or directory: '/.fastwqcfg.json' 2023-11-07 12:53:52,003 Config read DEBUG Reading file: /.fastwqcfg.json 2023-11-07 12:53:52,003 Config read ERROR can not find config file Traceback (most recent call last): File "/Users/chikane/Library/Application Support/Anki2/addons21/1956435337/context.py", line 79, in read with open(full_path, 'r', encoding="utf-8") as f: FileNotFoundError: [Errno 2] No such file or directory: '/.fastwqcfg.json' 2023-11-07 12:55:22,079 Config read DEBUG Reading file: /.fastwqcfg.json 2023-11-07 12:55:22,080 Config read ERROR can not find config file Traceback (most recent call last): File "/Users/chikane/Library/Application Support/Anki2/addons21/1956435337/context.py", line 79, in read with open(full_path, 'r', encoding="utf-8") as f: FileNotFoundError: [Errno 2] No such file or directory: '/.fastwqcfg.json' 2023-11-07 12:55:22,137 Config update DEBUG Update file: /_fastwqcfg.json 2023-11-07 12:55:22,137 Config update DEBUG Update data: {'1531111161104': {'list': [{'fields': [{'fld_name': '\u5355\u8bcd', 'fld_ord': 0, 'word_checked': True, 'dict_name': 'Baicizhan', 'dict_unique': 'Baicizhan', 'dict_fld_name': 'Audio Pronunciation', 'dict_fld_ord': 0, 'ignore': True, 'skip_valued': True, 'cloze_word': False}, {'fld_name': '\u53d1\u97f3', 'fld_ord': 1, 'word_checked': False, 'dict_name': 'Baicizhan', 'dict_unique': 'Baicizhan', 'dict_fld_name': 'Audio Pronunciation', 'dict_fld_ord': 0, 'ignore': True, 'skip_valued': True, 'cloze_word': False}, {'fld_name': '\u51fa\u5904', 'fld_ord': 2, 'word_checked': False, 'dict_name': 'Baicizhan', 'dict_unique': 'Baicizhan', 'dict_fld_name': 'Audio Pronunciation', 'dict_fld_ord': 0, 'ignore': True, 'skip_valued': True, 'cloze_word': False}, {'fld_name': '\u5b57\u51781', 'fld_ord': 3, 'word_checked': False, 'dict_name': 'Baicizhan', 'dict_unique': 'Baicizhan', 'dict_fld_name': 'Audio Pronunciation', 'dict_fld_ord': 0, 'ignore': True, 'skip_valued': True, 'cloze_word': False}, {'fld_name': '\u5b57\u51782', 'fld_ord': 4, 'word_checked': False, 'dict_name': 'Baicizhan', 'dict_unique': 'Baicizhan', 'dict_fld_name': 'Audio Pronunciation', 'dict_fld_ord': 0, 'ignore': True, 'skip_valued': True, 'cloze_word': False}, {'fld_name': '\u5b57\u51783', 'fld_ord': 5, 'word_checked': False, 'dict_name': 'Baicizhan', 'dict_unique': 'Baicizhan', 'dict_fld_name': 'Audio Pronunciation', 'dict_fld_ord': 0, 'ignore': True, 'skip_valued': True, 'cloze_word': False}, {'fld_name': '\u5b57\u51784', 'fld_ord': 6, 'word_checked': False, 'dict_name': 'Baicizhan', 'dict_unique': 'Baicizhan', 'dict_fld_name': 'Audio Pronunciation', 'dict_fld_ord': 0, 'ignore': True, 'skip_valued': True, 'cloze_word': False}, {'fld_name': '\u5b57\u51785', 'fld_ord': 7, 'word_checked': False, 'dict_name': 'Baicizhan', 'dict_unique': 'Baicizhan', 'dict_fld_name': 'Audio Pronunciation', 'dict_fld_ord': 0, 'ignore': True, 'skip_valued': True, 'cloze_word': False}, {'fld_name': '\u5b57\u51786', 'fld_ord': 8, 'word_checked': False, 'dict_name': 'Baicizhan', 'dict_unique': 'Baicizhan', 'dict_fld_name': 'Audio Pronunciation', 'dict_fld_ord': 0, 'ignore': True, 'skip_valued': True, 'cloze_word': False}, {'fld_name': 'url', 'fld_ord': 9, 'word_checked': False, 'dict_name': 'Baicizhan', 'dict_unique': 'Baicizhan', 'dict_fld_name': 'Audio Pronunciation', 'dict_fld_ord': 0, 'ignore': True, 'skip_valued': True, 'cloze_word': False}], 'name': 'Config 1'}], 'def': 0}, 'last_model': 1531111161104, 'version': 'v3.0.0', 'chikane_last': 1531111161104} 2023-11-07 12:56:32,413 Config update DEBUG Update file: /_fastwqcfg.json 2023-11-07 12:56:32,414 Config update DEBUG Update data: {'1531111161104': {'list': [{'fields': [{'fld_name': '\u5355\u8bcd', 'fld_ord': 0, 'word_checked': True, 'dict_name': 'Baicizhan', 'dict_unique': 'Baicizhan', 'dict_fld_name': 'Audio Pronunciation', 'dict_fld_ord': 0, 'ignore': True, 'skip_valued': True, 'cloze_word': False}, {'fld_name': '\u53d1\u97f3', 'fld_ord': 1, 'word_checked': False, 'dict_name': 'Baicizhan', 'dict_unique': 'Baicizhan', 'dict_fld_name': 'Audio Pronunciation', 'dict_fld_ord': 0, 'ignore': True, 'skip_valued': True, 'cloze_word': False}, {'fld_name': '\u51fa\u5904', 'fld_ord': 2, 'word_checked': False, 'dict_name': 'Baicizhan', 'dict_unique': 'Baicizhan', 'dict_fld_name': 'Audio Pronunciation', 'dict_fld_ord': 0, 'ignore': True, 'skip_valued': True, 'cloze_word': False}, {'fld_name': '\u5b57\u51781', 'fld_ord': 3, 'word_checked': False, 'dict_name': 'Baicizhan', 'dict_unique': 'Baicizhan', 'dict_fld_name': 'Audio Pronunciation', 'dict_fld_ord': 0, 'ignore': True, 'skip_valued': True, 'cloze_word': False}, {'fld_name': '\u5b57\u51782', 'fld_ord': 4, 'word_checked': False, 'dict_name': 'Baicizhan', 'dict_unique': 'Baicizhan', 'dict_fld_name': 'Audio Pronunciation', 'dict_fld_ord': 0, 'ignore': True, 'skip_valued': True, 'cloze_word': False}, {'fld_name': '\u5b57\u51783', 'fld_ord': 5, 'word_checked': False, 'dict_name': 'Baicizhan', 'dict_unique': 'Baicizhan', 'dict_fld_name': 'Audio Pronunciation', 'dict_fld_ord': 0, 'ignore': True, 'skip_valued': True, 'cloze_word': False}, {'fld_name': '\u5b57\u51784', 'fld_ord': 6, 'word_checked': False, 'dict_name': 'Baicizhan', 'dict_unique': 'Baicizhan', 'dict_fld_name': 'Audio Pronunciation', 'dict_fld_ord': 0, 'ignore': True, 'skip_valued': True, 'cloze_word': False}, {'fld_name': '\u5b57\u51785', 'fld_ord': 7, 'word_checked': False, 'dict_name': 'Baicizhan', 'dict_unique': 'Baicizhan', 'dict_fld_name': 'Audio Pronunciation', 'dict_fld_ord': 0, 'ignore': True, 'skip_valued': True, 'cloze_word': False}, {'fld_name': '\u5b57\u51786', 'fld_ord': 8, 'word_checked': False, 'dict_name': 'Baicizhan', 'dict_unique': 'Baicizhan', 'dict_fld_name': 'Audio Pronunciation', 'dict_fld_ord': 0, 'ignore': True, 'skip_valued': True, 'cloze_word': False}, {'fld_name': 'url', 'fld_ord': 9, 'word_checked': False, 'dict_name': 'Baicizhan', 'dict_unique': 'Baicizhan', 'dict_fld_name': 'Audio Pronunciation', 'dict_fld_ord': 0, 'ignore': True, 'skip_valued': True, 'cloze_word': False}], 'name': 'Config 1'}], 'def': 0}, 'last_model': 1531111161104, 'version': 'v3.0.0', 'chikane_last': 1531111161104} 2023-11-07 12:59:45,567 root INFO Logger is configured: file=/Users/chikane/Library/Application Support/Anki2/addons21/1956435337/fastwordquery-3.log 2023-11-07 12:59:45,874 Config read DEBUG Reading file: /Users/chikane/Library/Application Support/Anki2/chikane/collection.media/_fastwqcfg.json

I tried to add the following code to the context.py file,then the addon works fine now.

wp = mw.pm.profileFolder() mediaPath = os.path.join(wp, "collection.media") os.chdir(mediaPath)

Screenshot 2023-11-07 at 12 59 24

Hi @SOREMUZ , Thanks for reporting

This error happens if Anki can't write "Fast Word Query" config file (_fastwqcfg.json) into the user's home directory. I guess it will be /Users/chikane/_fastwqcfg.json on your machine. This is related to filesystem configuration of your machine. To simplify your investigation I added full path to log and to error message. E.g. 2023-11-07 00:20:20,422 Config update DEBUG Update file: /home/aleks/_fastwqcfg.json.

Try to update the add-on, find exact path to the config file and check why this file is read-only.

Logs location on your machine: /Users/chikane/Library/Application Support/Anki2/addons21/1956435337/fastwordquery-3.log

Please, let me know about the results.

Aleks-Ya commented 8 months ago

Hi @SOREMUZ ,

I see in your logs that you're running Anki from the file system root (/). So, "Fast Query Word" add-on tries to write config to /_fastwqcfg.json, but this folder is read-only.

I modified add-on logic in such way that it stores config file into "user home directory" instead of "current working directory". In your case, the config file will be stored at /Users/chikane/_fastwqcfg.json, which is writable usually. Please, upgrade your Anki to the latest version.

In your code snippet, you store the config file within the collection data directory, which is not a proper place for plugin configs. Copy you config /Users/chikane/Library/Application Support/Anki2/chikane/collection.media/_fastwqcfg.json to /Users/chikane/_fastwqcfg.json to preserve your settings.