chenyanming / calibredb.el

Emacs calibre client - An Ebook Management Solution in Emacs.
GNU General Public License v3.0
323 stars 17 forks source link

INVALID LIBRARY #36

Closed onnyyonn closed 3 years ago

onnyyonn commented 3 years ago

My config looks like this:

(use-package calibredb
  :defer t
  :init
  (autoload 'calibredb "calibredb")
  :config
  (setq calibredb-root-dir "~/Nextcloud/Books/Calibre/")
  (setq calibredb-db-dir (expand-file-name "metadata.db" calibredb-root-dir))
  (setq calibredb-library-alist '(("~/Nextcloud/Books/Calibre/")))
  (setq calibredb-format-all-the-icons t))

I can confirm that calibredb and sqlite3 are in system path (\usr\bin). metadata.db exists in the directory ~/Nextcloud/Books/Calibre/, which is both calibredb-root-dir and calibredb-library for me. I have also looked at the suggestions given at #6 and #15 . I still get INBALID LIBRARY error when I try to run calibredb-find-counsel.

chenyanming commented 3 years ago
  1. Did you try to use calibre to generate an empty library and read by calibredb.el? If it is ok, maybe your metadata was broken.
  2. If it still not ok, try to find that if .sqliterc is existed or not? Try to delete .sqliterc and try again. Post the content of .sqliterc here.
  3. If it still no ok, post your calibre version and sqlite version. I will check if the version problems.
onnyyonn commented 3 years ago
  1. Tested on an empty library. Still getting INVALID LIBRARY error.
  2. There is no .sqliterc in my home directory.
  3. Calibre version 5.12 and Sqlite3 version 3.34.1
chenyanming commented 3 years ago

What operating system do you use? If your are windows, is it using utf8, try to enable utf8?

chenyanming commented 3 years ago

Would you like to switch to calibredb.el 2.8.0 and test again? 2.9.0 was just released yesterday and maybe some bugs on it.

chenyanming commented 3 years ago

Try to send the metadata.db to me (you can upload to github) and I will test on it.

onnyyonn commented 3 years ago

I am using Manjaro Linux with KDE Plasma. It is using UTF-8.

I tried calibredb.el 2.8.0. The error persists still. In case it matters, I am using Doom Emacs and this is how the installation looks like in my packages.el:

(package! calibredb :pin "a62d7de582b16490b1af5add7b24a67022be531b")

Here is metadata.db.zip

(Thanks for your patience to solve this issue btw. Really appreciate it.)

chenyanming commented 3 years ago

I've download the latest calibre 5.13 and latest sqite3 3.35.2, and set them with

  (setq calibredb-program "/Users/chandamon/Downloads/calibre.app/Contents/MacOS/calibredb")
  (setq sql-sqlite-program "/Users/chandamon/Downloads/sqlite-tools-osx-x86-3350200/sqlite3")

and tested your metadata.db, it works perfectly.

Screenshot 2021-03-22 at 10 33 16

Would you try to set calibredb-program and sql-sqlite-program in your config and try?

onnyyonn commented 3 years ago

I have tried a few things, like updating Calibre and Sqlite and setting calibredb-program and sql-sqlite-program in the config. They didn't help. But finally I made it work by removing :defer t from the config. I have no idea why that would happen though.

Anyway, the package is working for me now. Please feel free to close the issue.

onnyyonn commented 3 years ago

Some more info on this bug:

I tried the following config to see if I can use it with defer

(use-package calibredb
  :defer t
  :init
  (autoload 'calibredb "calibredb")
  (setq calibredb-root-dir "~/Nextcloud/Books/Calibre/")
  (setq calibredb-db-dir (expand-file-name "metadata.db" calibredb-root-dir))
  (setq calibredb-library-alist '(("~/Nextcloud/Books/Calibre/")))
  (setq calibredb-format-all-the-icons t))

And it works. But there is one issue - the function calibredb is not there anymore! All other functions such as calibredb-find-counsel, calibredb-list etc. are still there and works as expected.

dalanicolai commented 3 years ago

@onnyyonn Although I don't know why adding that autoload form in the :init would make the calibredb function unavailable, you shouldn't need that autoload form as the calibredb function already has a "magic" comment to make it autoloadable,

Also, just for your information, if you do want/need to make a function autoloadable via the use-package macro then you can use the :command keyword for that as documented here (note that it additionally mentions that you do not need the :defer keyword when you are using the :command keyword).

onnyyonn commented 3 years ago

@dalanicolai thanks for the suggestions. It seems removing the autoload fixes all problems. Right now my cofig looks like this:

(use-package calibredb
  :defer t
  :config
  (setq calibredb-root-dir "~/Nextcloud/Books/Calibre/")
  (setq calibredb-db-dir (expand-file-name "metadata.db" calibredb-root-dir))
  (setq calibredb-library-alist '(("~/Nextcloud/Books/Calibre/")))
  (setq calibredb-format-all-the-icons t))

and everything is working as intended. By the way, I think the Readme should be updated with removing the autoload, as it's not needed and may cause issues.

dalanicolai commented 3 years ago

Ah yes, you are right. I'm sure @chenyanming will take care of this...

Anyway great that it works now... enjoy this great package!

chenyanming commented 3 years ago

README was updated. Now it can be closed.