1

I'm struggling to set up Org-Roam on a minimal GUIX set-up. There is an attempt to compile Compiling EmacSQL SQL binary which throws an error No EmacSQL SQLite binary available. I have installed both gcc and clang and the correct path (ie. the same as is returned by which gcc) is found using eg. (executable-find "clang") (the code tries gcc before clang so I have tried removing the former with the same results). With apologies, I am typing out a couple of lines of the *Backtrace* as my GUIX is a very minimal writing set-up but the first two lines are the following:

error("No EmacSQL SQLite binary available, aborting")
emacsql-sqlite-ensure-binary()

This error is thrown by, for example, running (org-roam-node-find) The *Backtrace* shows a call to make-instance(emacsql-sqlite-connection :file "~/.emacs.d/org-roam.db") followed by a number of calls such as apply(#f(compiled-function (&rest args) #<bytecode [...])(#<emacs-sqlite-connection emacsql-sqlite-connection-[...]> (:file "~/.emacs.d/org-roam.db")).

A file named emacsql-sqlite.elc (7.4k) exists in a directory in .emacs.d/elpa/emacsql-sqlite-20230118.2015. Another directory exists in .emacs.d/elpa/ named emacsql-20230118.2020. These directories are repopulated upon running (org-roam-node-find) when they are deleted or moved.

Internet searches have thrown up problems with Windows and Mac OS all of which appear to be resolved by installing gcc or clang.

Drew
  • 75,699
  • 9
  • 109
  • 225
krozruch
  • 13
  • 5
  • You should install the `sqlite3` package using your distro's package manager. This is not an Emacs problem. – NickD Jan 25 '23 at 22:39
  • It is installed. Typing `sqlite3` in eshell takes me to a SQL prompt, typing `which sqlite3` gives me its location, and executing `(executable-find "sqlite3")` in the \*scratch\* buffer gives me the same location. – krozruch Feb 01 '23 at 13:13
  • If you look at *how* `emacsql-sqlite-ensure-binary` tries to find the binary, it does `(file-exists-p emacsql-sqlite-executable)` - so you have to set `emacsql-sqlite-executable` to the full path of the binary you found above. In particular, it is *not* using `executable-find`. – NickD Feb 01 '23 at 14:50

1 Answers1

1

The OP checked that the sqlite3 binary is installed on his system and can be found by shells and through the executable-find mechanism. But the emacs-sqlite package uses emacsql-sqlite-ensure-binary (as the error message shows) and that uses its own mechanism:

;;; Ensure the SQLite binary is available

(defun emacsql-sqlite-ensure-binary ()
  "Ensure the EmacSQL SQLite binary is available, signaling an error if not."
  (unless (file-exists-p emacsql-sqlite-executable)
    ;; try compiling at the last minute
    (unless (ignore-errors (emacsql-sqlite-compile 2))
      (error "No EmacSQL SQLite binary available, aborting"))))

So the variable emacsql-sqlite-executable has to be set to the full path of the sqlite3 executable for this to work. Add the setting to the init file:

(setq emacsql-sqlite-executable "/path/to/sqlite3")
NickD
  • 27,023
  • 3
  • 23
  • 42
  • This is useful and I expected it to resolve the issue but it doesn't. Not yet. I'm picking this apart in \*scratch\*. `(file-exists-p emacsql-sqlite-executable)` reports true here but appears to evaluate as false in emacsql-sqlite.el. In the Scratch buffer, `(emacsql-sqlite-ensure-binary)` returns nil. I may try the guix irc or something here and will return to answer below if something turns up. – krozruch Feb 02 '23 at 09:38
  • Check to see what the `(emacsql-sqlite-compile 2)` call does: if it fails, then dig into that functions to see *why* it fails. – NickD Feb 02 '23 at 13:17
  • IOW, it's not that `file-exists-p` that returns different things in the two contexts (it's hard to imagine how that would happen). Instead, it's that `emacsql-sqlite-ensure-binary` fails because the *other* function that it calls (i.e. `emacsql-sqlite-compile`) fails. – NickD Feb 02 '23 at 14:14
  • Apologies for taking some time to mark this correct.. It gave me what I needed to debug this problem. The Guix set-up is intentionally a minimal writing set-up I tend to run offline and being variously neurodivergent I tend to be contextually either here or there.. I intended to document my debugging process but it's now a long time ago. From memory it related to misspellings of variables such as, I presume, emacsql-sqlite-executable. – krozruch Apr 17 '23 at 16:33