chenyanming / calibredb.el

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

Windows 10 - Issue with spaces in path? #58

Open nyambol opened 2 years ago

nyambol commented 2 years ago

M-x calibredb fails with:

Backtrace:

Debugger entered--Lisp error: (error "Error: ‘calibredb-query’ can’t query \"c:/Users/micha/Calibre Library/metadata.db\". switching to its error buffer")
  error("Error: `calibredb-query' can't query \"%s\". switching to its error buffer" "c:/Users/micha/Calibre Library/metadata.db")
  (if (= 0 (call-process-shell-command (format "%s -separator %s -newline %s -list -nullvalue '' -noheader %s \"%s\"" sql-sqlite-program calibredb-sql-separator calibredb-sql-newline (shell-quote-argument (expand-file-name calibredb-db-dir)) sql-query) nil (list out-buf t))) (save-current-buffer (set-buffer out-buf) (buffer-string)) (switch-to-buffer out-buf) (goto-char (point-min)) (error "Error: `calibredb-query' can't query \"%s\". switching to its error buffer" (expand-file-name calibredb-db-dir)))
  (if (not (file-exists-p calibredb-db-dir)) (message "calibredb-query: calibredb-db-dir is nil! calibredb-query won't work without it.") (if (= 0 (call-process-shell-command (format "%s -separator %s -newline %s -list -nullvalue '' -noheader %s \"%s\"" sql-sqlite-program calibredb-sql-separator calibredb-sql-newline (shell-quote-argument (expand-file-name calibredb-db-dir)) sql-query) nil (list out-buf t))) (save-current-buffer (set-buffer out-buf) (buffer-string)) (switch-to-buffer out-buf) (goto-char (point-min)) (error "Error: `calibredb-query' can't query \"%s\". switching to its error buffer" (expand-file-name calibredb-db-dir))))
  (let ((out-buf " *calibredb-query-output*")) (if (get-buffer out-buf) (progn (kill-buffer out-buf))) (if (not (file-exists-p calibredb-db-dir)) (message "calibredb-query: calibredb-db-dir is nil! calibredb-query won't work without it.") (if (= 0 (call-process-shell-command (format "%s -separator %s -newline %s -list -nullvalue '' -..." sql-sqlite-program calibredb-sql-separator calibredb-sql-newline (shell-quote-argument (expand-file-name calibredb-db-dir)) sql-query) nil (list out-buf t))) (save-current-buffer (set-buffer out-buf) (buffer-string)) (switch-to-buffer out-buf) (goto-char (point-min)) (error "Error: `calibredb-query' can't query \"%s\". switching to its error buffer" (expand-file-name calibredb-db-dir)))))
  calibredb-query("\nWITH d AS (\n    SELECT books.id, books.id as book, format, uncompressed_size, name\n    FROM books\n    LEFT JOIN data\n    ON books.id = data.book\n    WHERE data.book IS NULL\n    UNION\n    SELECT *\n   ...")
  (let* ((query-result (calibredb-query (concat calibredb-query-string (cond ((eq calibredb-sort-by 'id) (let nil " ORDER BY id")) ((eq calibredb-sort-by 'title) (let nil " ORDER BY title")) ((eq calibredb-sort-by 'author) (let nil " ORDER BY author_sort")) ((eq calibredb-sort-by 'format) (let nil " ORDER BY format")) ((eq calibredb-sort-by 'date) (let nil " ORDER BY last_modified")) ((eq calibredb-sort-by 'pubdate) (let nil " ORDER BY pubdate")) ((eq calibredb-sort-by 'tag) (let nil " ORDER BY tag")) ((eq calibredb-sort-by 'size) (let nil " ORDER BY uncompressed_size")) ((eq calibredb-sort-by 'language) (let nil " ORDER BY lang_code")) (t (let nil " ORDER BY id"))) (if (eq calibredb-order 'desc) (progn " DESC"))))) (line-list (split-string (calibredb-chomp query-result) calibredb-sql-newline))) (cond ((equal "" query-result) '("")) (t (let (res-list h-list f-list a-list) (let ((--dolist-tail-- line-list)) (while --dolist-tail-- (let ((line (car --dolist-tail--))) (if (string-match-p (concat "^[0-9]\\{1,10\\}" calibredb-sql-separator) line) (setq res-list (cons (calibredb-query-to-alist line) res-list))) (setq --dolist-tail-- (cdr --dolist-tail--))))) (let ((--dolist-tail-- res-list)) (while --dolist-tail-- (let ((item (car --dolist-tail--))) (cond ((string-match-p "archive" (calibredb-getattr (list item) :tag)) (setq res-list (remove item res-list)) (setq a-list (cons item a-list))) ((string-match-p "favorite" (calibredb-getattr (list item) :tag)) (setq res-list (remove item res-list)) (setq f-list (cons item f-list))) ((string-match-p "highlight" (calibredb-getattr (list item) :tag)) (setq res-list (remove item res-list)) (setq h-list (cons item h-list)))) (setq --dolist-tail-- (cdr --dolist-tail--))))) (setq res-list (nconc a-list res-list h-list f-list)) (calibredb-getbooklist res-list)))))
  calibredb-candidates()
  (setq calibredb-search-entries (calibredb-candidates))
  (or calibredb-search-entries (setq calibredb-search-entries (calibredb-candidates)))
  (let ((cand (or calibredb-search-entries (setq calibredb-search-entries (calibredb-candidates))))) (if calibredb-full-entries nil (setq calibredb-full-entries calibredb-search-entries)) (if (get-buffer (calibredb-search-buffer)) (progn (kill-buffer (calibredb-search-buffer)))) (if (equal calibredb-search-filter "") (setq calibredb-virtual-library-name calibredb-virtual-library-default-name)) (switch-to-buffer (calibredb-search-buffer)) (goto-char (point-min)) (if (equal cand '("")) nil (let ((--dolist-tail-- cand)) (while --dolist-tail-- (let ((item (car --dolist-tail--))) (let (beg end) (setq beg (point)) (insert (car item)) (calibredb-detailed-view-insert-image item) (setq end (point)) (put-text-property beg end 'calibredb-entry item) (insert "\n")) (setq --dolist-tail-- (cdr --dolist-tail--))))) (goto-char (point-min))) (calibredb-ref-default-bibliography) (if (eq major-mode 'calibredb-search-mode) nil (calibredb-search-mode)))
  (cond ((null calibredb-db-dir) (message "calibredb: calibredb-db-dir is nil! calibredb won't work without it.")) ((not (file-regular-p calibredb-db-dir)) (message "calibredb: %s doesn't exist!") calibredb-db-dir) (t (let ((cand (or calibredb-search-entries (setq calibredb-search-entries (calibredb-candidates))))) (if calibredb-full-entries nil (setq calibredb-full-entries calibredb-search-entries)) (if (get-buffer (calibredb-search-buffer)) (progn (kill-buffer (calibredb-search-buffer)))) (if (equal calibredb-search-filter "") (setq calibredb-virtual-library-name calibredb-virtual-library-default-name)) (switch-to-buffer (calibredb-search-buffer)) (goto-char (point-min)) (if (equal cand '("")) nil (let ((--dolist-tail-- cand)) (while --dolist-tail-- (let ((item (car --dolist-tail--))) (let (beg end) (setq beg (point)) (insert (car item)) (calibredb-detailed-view-insert-image item) (setq end (point)) (put-text-property beg end 'calibredb-entry item) (insert "\n")) (setq --dolist-tail-- (cdr --dolist-tail--))))) (goto-char (point-min))) (calibredb-ref-default-bibliography) (if (eq major-mode 'calibredb-search-mode) nil (calibredb-search-mode)))))
  calibredb()
  funcall-interactively(calibredb)
  command-execute(calibredb record)
  execute-extended-command(nil "calibredb" nil)
  funcall-interactively(execute-extended-command nil "calibredb" nil)
  command-execute(execute-extended-command)

But: calibredb-query-output is 'c:/Program' is not recognized as an internal or external command, operable program or batch file.

Config in init file:

(use-package calibredb :defer t
       :config
       (setq calibredb-root-dir "c:/Users/micha/Calibre Library")
       (setq calibredb-db-dir (expand-file-name "metadata.db" calibredb-root-dir))
       (setq calibredb-library-alist '(("c:/Users/micha/Calibre Library"))))

I put the Calibre directory in exec-path. It's already in the system path.

The tool itself works fine.

C:\Users\micha
{micha} [57] --> calibredb list
id  title                                                                       authors
1   Quick Start Guide                                                           John Schember
3   A Breach of Promise                                                         Anne Perry
4   Weighed in the Balance                                                      Anne Perry
5   We Shall Not Sleep                                                          Anne Perry
6   A Christmas Promise                                                         Anne Perry
7   A Christmas Homecoming                                                      Anne Perry
[ ... ]

Win 10 Pro GNU Emacs 29.0.50 (build 2, x86_64-w64-mingw32) of 2022-02-10

Thanks. mp

chenyanming commented 2 years ago

Having spaces in path is no problems. Can you run (calibredb-query "SELECT * FROM books")?

chenyanming commented 2 years ago

How about you setup calibredb-program?

nyambol commented 2 years ago

Hello,

I customized calibredb-program to the complete path. No joy. I then added the installation directory to exec-path and set it back to the default setting. The error is the same every time.

Thanks.

mp

On 3/1/2022 21:08, Damon Chan wrote:

How about you setup |calibredb-program|?

— Reply to this email directly, view it on GitHub https://github.com/chenyanming/calibredb.el/issues/58#issuecomment-1056061125, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7BKOH77UJALBONUUEE32DU53ETTANCNFSM5PVGN5EA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

-- "Do not neglect to do good, and to share what you have." - Hebrews 13:16a Michael Powe Naugatuck CT USA @.***

nyambol commented 2 years ago

Hello,

M-: |(calibredb-query "SELECT * FROM books")|

Same result in debugger and same output message.

Thanks.

mp

On 3/1/2022 21:04, Damon Chan wrote:

Having spaces in path is no problems. Can you run |(calibredb-query "SELECT * FROM books")|?

— Reply to this email directly, view it on GitHub https://github.com/chenyanming/calibredb.el/issues/58#issuecomment-1056058450, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7BKOG7OURFLS5QBMJTBWDU53ECFANCNFSM5PVGN5EA. Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

-- "Do not neglect to do good, and to share what you have." - Hebrews 13:16a Michael Powe Naugatuck CT USA @.***

nyambol commented 2 years ago

Hello,

It works correctly in Emacs 27.1. So, apparently, there's something in the new version that breaks it. "Forewarned is forearmed."

It looks great. Thanks for the work.

mp

chenyanming commented 2 years ago

As far as I know, the latest Emacs 29 integrates sqlite while this package relies on the external sqlite, so the package will be updated and use it when Emacs 29 becomes stable.