louietan / anki-editor

Emacs minor mode for making Anki cards with Org
699 stars 87 forks source link

Can't push notes on WSL2 #88

Closed code-SL closed 3 years ago

code-SL commented 3 years ago

(anki-editor-push-notes) leads to "End of File while parsing JSON" error on WSL2 (windows 10) in Emacs 26.

Request.el log (" request-log" buffer) is empty.

Tried on two different machines running WSL2 and coming up with the same issue. Can confirm that anki-connect is up. Can also confirm that .emacs configuration works for pushing notes in linux, so not sure if there is an issue with parsing JSON that is windows specific.

code-SL commented 3 years ago

Found that byte recompiling the .emacs.d folder ended up resolving this issue.

Still can't get it to work due to an error message indicating the below message. Still feels like a WSL2 issue.

:ANKI_FAILURE_REASON: Error communicating with AnkiConnect using cURL: exited abnormally with code 7

code-SL commented 3 years ago

Looks like this got complicated. WSL2 is effectively a VM, making localhost calls to win10 anki GUI not straightforward. You have to point emacs to the IP address of the windows machine defined in /etc/resolv.conf. Thus:

1) ensure that anki-connect's server in windows is accessible to any interface in order to accept connections from WSL2, 2) open the firewall for anki.exe, 3) set anki-editor listening address to be the address defined in resolv.conf in WSL2

Steps I followed to get it to work: