meedstrom / org-node

A notetaking system like Roam using Emacs Org-mode
GNU General Public License v3.0
156 stars 5 forks source link

invalid-function emacsql-with-transaction #17

Closed emacsomancer closed 3 months ago

emacsomancer commented 5 months ago

I get a delay when saving things with org-node, so I tried setting:

(setq org-roam-db-update-on-save nil) ;; don't update DB on save, not needed
(setq org-roam-link-auto-replace nil) ;; don't look for "roam:" links on save
(add-hook 'org-node-cache-rescan-file-hook #'org-node-feed-file-to-roam-db)

but now on save I get an error:

Debugger entered--Lisp error: (invalid-function emacsql-with-transaction)
  emacsql-with-transaction(#<emacsql-sqlite-builtin-connection emacsql-sqlite-builtin-connection-1eb455bd415c> nil)
  org-node-feed-file-to-roam-db()
  org-node-cache-rescan-file()
  run-hooks(after-save-hook)
  basic-save-buffer(t)
  save-buffer(1)
  funcall-interactively(save-buffer 1)
  command-execute(save-buffer)
meedstrom commented 5 months ago

Ah, because it's a macro... I added a (require 'emacsql) in the latest commit, let me know if it's fixed.

Not sure why I can't reproduce it, since I think I am loading the built version of org-node. A proper test suite might catch these things, feeling like an amateur here without one. I appreciate the bug reports :)

emacsomancer commented 5 months ago

with the latest updates, I still seem to be getting a related error:

  Debugger entered--Lisp error: (invalid-function emacsql-with-transaction)
    emacsql-with-transaction(#<emacsql-sqlite-builtin-connection emacsql-sqlite-builtin-connection-f8857a0> nil)
    org-node-feed-file-to-roam-db()
    org-node-cache-rescan-file()
    run-hooks(after-save-hook)
    basic-save-buffer(t)
    save-buffer(1)
    funcall-interactively(save-buffer 1)
    command-execute(save-buffer)

hmm... maybe I fixed it - going in and re-native-compiling org-node-roam.el (though I thought the package upgrade should automatically native compile it; I'm not sure why this particular file is an issue, though it's probably something on my end.

emacsomancer commented 5 months ago

No, for some reason I indeed seem to need to go and eval-buffer on the org-node-roam.el file after every restart. I'm confused as for why.

emacsomancer commented 5 months ago

This is perhaps fixed by modifying org-node-feed-file-to-roam-db to include (require 'org-roam) (before (require 'emacsql)).

emacsomancer commented 3 months ago

I'm getting this issue again on the new version:

Debugger entered--Lisp error: (invalid-function emacsql-with-transaction)
  emacsql-with-transaction(#<emacsql-sqlite-builtin-connection emacsql-sqlite-builtin-connection-fe76451> nil)
  org-node-roam-db-feed(("~/Documents/Org/org-roam/daily/2024-07-17.org"))
  org-node--finalize-modified((nil ("~/Documents/Org/org-roam/daily/2024-07-17.org") ((:title "journal" :is-subtree t :level 1 :id "6f4b7dcc-d2ba-462c-8256-c4ec808f2f6b" :pos 12274 :tags ("personal") :todo nil :file-path "~/Documents/Org/org-roam/daily/2024-07-17.org" :scheduled nil :deadline nil :file-title "2024-07-17" :file-title-or-basename "2024-07-17" :olp nil :properties (("ID" . "6f4b7dcc-d2ba-462c-8256-c4ec808f2f6b")) :priority nil :aliases nil :refs nil) (:title "2024-07-17" :level 0 :tags ("daily_journal") :file-path "~/Documents/Org/org-roam/daily/2024-07-17.org" :pos 1 :file-title "2024-07-17" :file-title-or-basename "2024-07-17" :properties (("LOCATION_SRC" . "wifi-alist") ("LOCATION" . "\"Hickory Hill Apts at 1375 North Dodge St #203 Iowa City, IA 52245\"") ("LAT-LONG" . "41.6772882,-91.5179891") ("MAIL" . "slade@lambda-y.net") ("AUTHOR" . "\"Benjamin Slade\"") ("CREATION_TIME" . "1721214254") ("ID" . "73ae69c6-fa01-4a73-968c-9129f5e3c5f9")) :id "73ae69c6-fa01-4a73-968c-9129f5e3c5f9" :aliases nil :refs nil)) nil ((:origin "6f4b7dcc-d2ba-462c-8256-c4ec808f2f6b" :pos 17071 :type "id" :dest "5ab1371b-282d-454a-bea4-789566e8558f" :properties (:outline ("dream"))) (:origin "6f4b7dcc-d2ba-462c-8256-c4ec808f2f6b" :pos 16850 :type "id" :dest "34cc8292-ebd6-4e46-944d-2a70c9b73d11" :properties (:outline ("dream"))) (:origin "6f4b7dcc-d2ba-462c-8256-c4ec808f2f6b" :pos 16286 :type "id" :dest "5d3b7f58-ae86-4d3e-ab50-cd9112df8bdd" :properties (:outline ("dream"))) (:origin "73ae69c6-fa01-4a73-968c-9129f5e3c5f9" :pos 396 :type "id" :dest "7bfe2836-bb7e-446e-9bbd-6c3bcebdcb5f" :properties (:outline ("org-node error"))) (:origin "73ae69c6-fa01-4a73-968c-9129f5e3c5f9" :pos 396 :type "id" :dest "7bfe2836-bb7e-446e-9bbd-6c3bcebdcb5f" :properties (:outline ("org-node error")))) nil nil (26264 19193 555835 947000)))
  org-node--handle-finished-job(1 org-node--finalize-modified)
  #f(compiled-function (process event) #<bytecode -0x1547969ed3160ff0>)(#<process org-node-0> "finished\n")

if I have org-node-roam-db-shim-mode enabled.

meedstrom commented 3 months ago

Good morning (or afternoon in SE Asia?)

I moved the require statements to top of file. Maybe it works now after upgrade & compile?

FYI there's another round of renamings but you'll get messages about it, sorry...

emacsomancer commented 3 months ago

I will have to try playing round with it again, but currently I'm trying "Option 1c" and cutting out the SQLite database entirely and that seems to resolve a number of issues for me (and be faster overall), but I just started using it, so I may be mistaken about what might and might not work.

meedstrom commented 3 months ago

It won't matter anymore, I realized I should add no-byte-compile to the fakeroam.el local variables, because org-roam and emacsql are not declared dependencies of the main package, so an user that doesn't also install org-roam could get compile errors on this file (if I understand correctly).

EDIT: To compile it, I'd have to externalize it as a second package... heh.