org-roam / org-roam

Rudimentary Roam replica with Org-mode
https://www.orgroam.com
GNU General Public License v3.0
5.4k stars 471 forks source link

emacsql-sqlite connecttion fails after upgrading to emacs 29 #2374

Open ramos opened 11 months ago

ramos commented 11 months ago

Description

After upgrading emacs, and pulling the latest version of all repos (using straight), org-roam fails to connect to the database:

Steps to Reproduce

Installing org-roam, with this config:

(use-package org-roam
  :ensure t
  :straight (:type git :host github :repo "org-roam/org-roam" :files (:defaults "extensions/*"))
  :custom
  (org-roam-directory "/home/alberto/cloud/documents/roam")
  (org-roam-db-location "/home/alberto/cloud/documents/roam/org-roam.db")
  :config
  (setq org-roam-database-connector 'sqlite)
  (setq org-roam-v2-ack t)
  (setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face'org-tag)))
  (org-roam-db-autosync-mode)
  (setq org-roam-mode-section-functions
    (list #'org-roam-backlinks-section
          #'org-roam-reflinks-section)))

crashes.

Backtrace

Debugger entered--Lisp error: (invalid-slot-name "#<emacsql-sqlite-connection emacsql-sqlite-connect..." handle)
  signal(invalid-slot-name ("#<emacsql-sqlite-connection emacsql-sqlite-connect..." handle))
  slot-missing(#<emacsql-sqlite-connection emacsql-sqlite-connection-15fd9dc> handle oset #<process emacsql-sqlite<13>>)
  eieio-oset(#<emacsql-sqlite-connection emacsql-sqlite-connection-15fd9dc> handle #<process emacsql-sqlite<13>>)
  #f(compiled-function (connection &rest rest) #<bytecode 0x11a662d0e14f4d5b>)(#<emacsql-sqlite-connection emacsql-sqlite-connection-15fd9dc> (:file "/home/alberto/cloud/documents/roam/org-roam.db"))
  apply(#f(compiled-function (connection &rest rest) #<bytecode 0x11a662d0e14f4d5b>) (#<emacsql-sqlite-connection emacsql-sqlite-connection-15fd9dc> (:file "/home/alberto/cloud/documents/roam/org-roam.db")))
  #f(compiled-function (&rest args) #<bytecode 0xef44d1fc038e0d1>)(#<emacsql-sqlite-connection emacsql-sqlite-connection-15fd9dc> (:file "/home/alberto/cloud/documents/roam/org-roam.db"))
  apply(#f(compiled-function (&rest args) #<bytecode 0xef44d1fc038e0d1>) #<emacsql-sqlite-connection emacsql-sqlite-connection-15fd9dc> (:file "/home/alberto/cloud/documents/roam/org-roam.db"))
  initialize-instance(#<emacsql-sqlite-connection emacsql-sqlite-connection-15fd9dc> (:file "/home/alberto/cloud/documents/roam/org-roam.db"))
  #f(compiled-function (class &rest slots) "Default constructor for CLASS `eieio-default-superclass'.\nSLOTS are the initialization slots used by `initialize-instance'.\nThis static method is called when an object is constructed.\nIt allocates the vector used to represent an EIEIO object, and then\ncalls `initialize-instance' on that object." #<bytecode -0x1db53534fb74c6a8>)(emacsql-sqlite-connection :file "/home/alberto/cloud/documents/roam/org-roam.db")
  apply(#f(compiled-function (class &rest slots) "Default constructor for CLASS `eieio-default-superclass'.\nSLOTS are the initialization slots used by `initialize-instance'.\nThis static method is called when an object is constructed.\nIt allocates the vector used to represent an EIEIO object, and then\ncalls `initialize-instance' on that object." #<bytecode -0x1db53534fb74c6a8>) emacsql-sqlite-connection (:file "/home/alberto/cloud/documents/roam/org-roam.db"))
  make-instance(emacsql-sqlite-connection :file "/home/alberto/cloud/documents/roam/org-roam.db")
  emacsql-sqlite("/home/alberto/cloud/documents/roam/org-roam.db")
  org-roam-db()
  org-roam-db-sync()
  org-roam-db-autosync-mode()
  (progn (setq org-roam-database-connector 'sqlite) (setq org-roam-v2-ack t) (setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag))) (org-roam-db-autosync-mode) (setq org-roam-mode-section-functions (list #'org-roam-backlinks-section #'org-roam-reflinks-section)) t)
  (condition-case err (progn (setq org-roam-database-connector 'sqlite) (setq org-roam-v2-ack t) (setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag))) (org-roam-db-autosync-mode) (setq org-roam-mode-section-functions (list #'org-roam-backlinks-section #'org-roam-reflinks-section)) t) ((debug error) (funcall use-package--warning125 :config err)))
  (if (not (require 'org-roam nil t)) (display-warning 'use-package (format "Cannot load %s" 'org-roam) :error) (condition-case err (progn (setq org-roam-database-connector 'sqlite) (setq org-roam-v2-ack t) (setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag))) (org-roam-db-autosync-mode) (setq org-roam-mode-section-functions (list #'org-roam-backlinks-section #'org-roam-reflinks-section)) t) ((debug error) (funcall use-package--warning125 :config err))))
  (progn (let ((custom--inhibit-theme-enable nil)) (if (memq 'use-package custom-known-themes) nil (custom-declare-theme 'use-package 'use-package-theme nil (list)) (enable-theme 'use-package) (setq custom-enabled-themes (remq 'use-package custom-enabled-themes))) (custom-theme-set-variables 'use-package '(org-roam-directory "/home/alberto/cloud/documents/roam" nil nil "Customized with use-package org-roam") '(org-roam-db-location "/home/alberto/cloud/documents/roam/org-roam.db" nil nil "Customized with use-package org-roam"))) (if (not (require 'org-roam nil t)) (display-warning 'use-package (format "Cannot load %s" 'org-roam) :error) (condition-case err (progn (setq org-roam-database-connector 'sqlite) (setq org-roam-v2-ack t) (setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" 'face 'org-tag))) (org-roam-db-autosync-mode) (setq org-roam-mode-section-functions (list #'org-roam-backlinks-section #'org-roam-reflinks-section)) t) ((debug error) (funcall use-package--warning125 :config err)))))
  (condition-case err (progn (let ((custom--inhibit-theme-enable nil)) (if (memq 'use-package custom-known-themes) nil (custom-declare-theme 'use-package 'use-package-theme nil (list)) (enable-theme 'use-package) (setq custom-enabled-themes (remq 'use-package custom-enabled-themes))) (custom-theme-set-variables 'use-package '(org-roam-directory "/home/alberto/cloud/documents/roam" nil nil "Customized with use-package org-roam") '(org-roam-db-location "/home/alberto/cloud/documents/roam/org-roam.db" nil nil "Customized with use-package org-roam"))) (if (not (require 'org-roam nil t)) (display-warning 'use-package (format "Cannot load %s" 'org-roam) :error) (condition-case err (progn (setq org-roam-database-connector 'sqlite) (setq org-roam-v2-ack t) (setq org-roam-node-display-template (concat "${title:*} " (propertize "${tags:10}" ... ...))) (org-roam-db-autosync-mode) (setq org-roam-mode-section-functions (list #'org-roam-backlinks-section #'org-roam-reflinks-section)) t) ((debug error) (funcall use-package--warning125 :config err))))) ((debug error) (funcall use-package--warning125 :catch err)))
  (progn (straight-use-package '(org-roam :type git :host github :repo "org-roam/org-roam" :files (:defaults "extensions/*") :flavor melpa)) (defvar use-package--warning125 #'(lambda (keyword err) (let ((msg (format "%s/%s: %s" ... keyword ...))) (display-warning 'use-package msg :error)))) (condition-case err (progn (let ((custom--inhibit-theme-enable nil)) (if (memq 'use-package custom-known-themes) nil (custom-declare-theme 'use-package 'use-package-theme nil (list)) (enable-theme 'use-package) (setq custom-enabled-themes (remq 'use-package custom-enabled-themes))) (custom-theme-set-variables 'use-package '(org-roam-directory "/home/alberto/cloud/documents/roam" nil nil "Customized with use-package org-roam") '(org-roam-db-location "/home/alberto/cloud/documents/roam/org-roam.db" nil nil "Customized with use-package org-roam"))) (if (not (require 'org-roam nil t)) (display-warning 'use-package (format "Cannot load %s" 'org-roam) :error) (condition-case err (progn (setq org-roam-database-connector 'sqlite) (setq org-roam-v2-ack t) (setq org-roam-node-display-template (concat "${title:*} " ...)) (org-roam-db-autosync-mode) (setq org-roam-mode-section-functions (list ... ...)) t) ((debug error) (funcall use-package--warning125 :config err))))) ((debug error) (funcall use-package--warning125 :catch err))))
  elisp--eval-last-sexp(nil)
  eval-last-sexp(nil)
  funcall-interactively(eval-last-sexp nil)
  command-execute(eval-last-sexp)

Expected Results

working org-roam

Actual Results

org-roam fails

Environment

void linux on emacs 20.0.92

Trevoke commented 11 months ago

My understanding of what we need to do here (from asking this question a long time ago) is that you need something like the following.

First, make sure emacs 29 is configured with sqlite support (unsure it's possible to compile it without, but turn it off and on again, you know?)

Then:

  (use-package emacsql-sqlite-builtin :pin melpa)
  (use-package org-roam
    :pin melpa
    :after org
    :after (org emacsql-sqlite-builtin)

    :ensure t
    :custom
    (org-roam-database-connector 'sqlite-builtin))

I believe this will get you up and running.

ramos commented 11 months ago

With your suggested changes, I get the error message:

Debugger entered--Lisp error: (error "Archive ’melpa’ requested for package ’emacsql-sql...")
  error("Archive '%s' requested for package '%s' is not available" "melpa" emacsql-sqlite-builtin)

But If I remove the :pin melpa everything seems to work now

Many thanks

Trevoke commented 11 months ago

Ah sorry, that was the last bit specific to my config. Glad it's working for you now :D

But yes, this is probably worth a section in the documentation somewhere, I couldn't find it yesterday.

ramos commented 11 months ago

Certainly this should be written down somewhere in the documentation

Many thanks!

A.

muep commented 11 months ago

The emacsql-sqlite-builtin package does not seem to be available yet in melpa-stable. Any idea if this is simply a matter of melpa-stable shipping code that is not yet fully compatible with Emacs 29.1, or is there some other action to fix this for a user that uses Emacs 29.1 and melpa-stable?

Trevoke commented 11 months ago

That is ... Probably a matter of asking the emacsql-sqlite-builtin folks to create a stable tag. There's a divergence in the emacs community about the importance of stable tags, IIRC (I believe there's an open issue on the melpa repository about it, holding the conversation).

Note that this is purely conjecture on my part.

jmay commented 11 months ago

For others reading this, the MacOS build of 29.1 that is posted at https://emacsformacosx.com/ does not appear to have been built with sqlite support.

But the version at https://github.com/railwaycat/homebrew-emacsmacport does have sqlite builtin. More testing needed, but it's the best pre-compiled Mac version I've found so far.