chenyanming / anki.el

Emacs Anki Client
90 stars 3 forks source link

Stop working after updating #2

Closed ram535 closed 4 years ago

ram535 commented 4 years ago

M-x anki throw this message json-read: JSON readtable error: 2.

Debugging:

(setq debug-on-error t)

Debugger entered--Lisp error: (json-readtable-error 2)
  signal(json-readtable-error (2))
  json-read()
  json-read-from-string("\2")
  anki-parse-decks()
  anki-parse-cards()
  anki-format-cards()
  anki()
  funcall-interactively(anki)
  call-interactively(anki record nil)
  command-execute(anki record)
  execute-extended-command(nil "anki" nil)
  funcall-interactively(execute-extended-command nil "anki" nil)
  call-interactively(execute-extended-command nil nil)
  command-execute(execute-extended-command)
chenyanming commented 4 years ago

Would you help run

(anki-query anki-query-decks) and copy the results to me?

chenyanming commented 4 years ago

Is anki-browser stop working as well?

ram535 commented 4 years ago

anki-browser is not working either.

(anki-query anki-query-decks) result "^B"

chenyanming commented 4 years ago

Would you try run sqlite3 collection.anki2 "SELECT decks FROM col" under the collection folder? Besides, I tempory made a fix 4f1b68a.

chenyanming commented 4 years ago

Since official Anki Client will lock the database when it opens, which make anki.el can not read the database. Copy the database is for temporary reading.

ram535 commented 4 years ago

I run sqlite3 collection.anki2 "SELECT decks FROM col" but I do not have idea for what it is for? image I did not show any output. I mean I do not know if I should expect any output.

Since official Anki Client will lock the database when it opens, which make anki.el can not read the database. Copy the database is for temporary reading.

Sorry I do not know what you mean. Should I copy the database?

After updating, the error did not disappear.

chenyanming commented 4 years ago

Seems your database does not have the decks data, since col column saves the decks information. It would be helpful if you share the database to me to further study.

chenyanming commented 4 years ago

I mean Anki.el copies the database to temp folder and read the copied file. Anki.el does not read the original database file. If your database does not have the col column, it maybe the database corrupts.

ram535 commented 4 years ago

I see, here is the database.

collection.anki2.zip

ram535 commented 4 years ago

I used https://github.com/louietan/anki-editor to add content to my decks. To be able to add content to the decks, anki has to open and have the https://github.com/FooSoft/anki-connect#installation plugin.

chenyanming commented 4 years ago

One note here, if anki keeps open, it will lock the database, and any modification saves to a wal and a shm file. Only you close anki, the changes will be saved to collection.anki2.

anki.el only reads the copy of collection.anki2.

I can not find a realible way to handle the wal and shm files so far. Therefore, if you want the changes applied and shown in anki.el, you have to close anki.

chenyanming commented 4 years ago

Since the database can not sync between anki.el and anki in real time, it is difficult for me to handle some anki original data, such as the review logs.

Anki is very complicated and big, which makes people can not easily port the features. People tend to implement plugins rather than replica. Besides, I am not a fan of the original anki client, what I like is the deck resources and anki's editing card features. Therefore, anki.el will go lighter and will implement its own review feature in the future. Anki is only providing the database.

Actually, I already implemented the anki-connect feature to control the anki client to show and anwer the card. But anki connect is very slow, and keeps anki opening makes me distracted...

ram535 commented 4 years ago

Nice, I like your approach. I am not a elisp hacker but if you need help testing stuff, I would gladly help.

When I have tested M-x anki, anki was not opened.

Have you checked https://github.com/l3kn/org-fc, I think it has more futures than org-drill. For example org-fc has input cards (you type the answer) similar as anki does it.

The only thing that stop me from using org-fc is that I cannot use it in my phone

chenyanming commented 4 years ago

I am really happy that you provide supports and help!

By the way, I tested your collection.anki2, seems it is corrupted, or may not supported in new anki? Which version of anki are you using? I am using Anki Version 2.1.15 (442df9d6).

Screenshot 2020-09-21 at 09 53 42

I recommend you use the latest anki client to regenerate the database.

chenyanming commented 4 years ago

Or maybe your database format is too new....Your collection.anki2 version is 15. Mine is 11. Let me check...

chenyanming commented 4 years ago

I follow the https://github.com/ankidroid/Anki-Android/wiki/Database-Structure

chenyanming commented 4 years ago

I checked. Anki did change the database format in later versions. https://changes.ankiweb.net/#/

Changes
warning After using the latest version, if you wish to open your collection with an earlier Anki release, please go to the File>Switch Profile menu item, and click on “Downgrade & Quit”. If you skip this step, you may get an error message when opening your collection in an older Anki version, and you will need to return to this version, downgrade, then try again.
chenyanming commented 4 years ago

You have to downgrade the anki database and check again.

https://forums.ankiweb.net/t/json-decoder-jsondecodeerror-expecting-value-line-1-column-1-char-0/622/3

For latest database format, I may wait the stable anki client version come out first. Since the database is still new and does not have enough document for me to integrate.

ram535 commented 4 years ago

Indeed that was the problem. I was using anki version 2.1.33.

But it seems I do not need to install an older version.

If I do File>Switch Profile menu item, and click on “Downgrade & Quit”. M-x anki works fine.

hpfr commented 2 years ago

Could you post here or cut a release when the new database format is supported? I think I'd rather use the Anki app and wait until anki.el supports the new database format than have to downgrade my database.

Thanks for your work on this package!

czqhurricnae commented 1 year ago

确实很糟糕,这个包不支持哪个版本的 Anki 应该在 README 写清楚。花时间装上发现不支持,就是浪费时间了。