Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop working after updating #2

Closed
ram535 opened this issue Sep 19, 2020 · 21 comments
Closed

Stop working after updating #2

ram535 opened this issue Sep 19, 2020 · 21 comments

Comments

@ram535
Copy link

ram535 commented Sep 19, 2020

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
Copy link
Owner

Would you help run

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

@chenyanming
Copy link
Owner

Is anki-browser stop working as well?

@ram535
Copy link
Author

ram535 commented Sep 20, 2020

anki-browser is not working either.

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

@chenyanming
Copy link
Owner

chenyanming commented Sep 20, 2020

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

@chenyanming chenyanming reopened this Sep 20, 2020
@chenyanming
Copy link
Owner

chenyanming commented Sep 20, 2020

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
Copy link
Author

ram535 commented Sep 20, 2020

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
Copy link
Owner

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
Copy link
Owner

chenyanming commented Sep 20, 2020

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
Copy link
Author

ram535 commented Sep 20, 2020

I see, here is the database.

collection.anki2.zip

@ram535
Copy link
Author

ram535 commented Sep 20, 2020

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
Copy link
Owner

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
Copy link
Owner

chenyanming commented Sep 20, 2020

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
Copy link
Author

ram535 commented Sep 20, 2020

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
Copy link
Owner

chenyanming commented Sep 21, 2020

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
Copy link
Owner

chenyanming commented Sep 21, 2020

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

@chenyanming
Copy link
Owner

@chenyanming
Copy link
Owner

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
Copy link
Owner

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
Copy link
Author

ram535 commented Sep 21, 2020

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
Copy link

hpfr commented Feb 1, 2022

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants