Emacs can't find sqlite3

In another post I was advised that, before figuring out how to install org-roam declaratively, I could install it procedurally. So I did.

org-roam uses sqlite, via emacs-sqlite3. Both are installed, but it claims not to find sqlite3. When I start Emacs it tries to run org-roam, which tries to run emacs-sqlite3, which produces the error below.

To reach that point I added sqlite to the packages in my environment.systemPackages variable in my configuration.nix file, added use-package and emacs-sqlite3 to my emacs packages, rebuilt, installed org-roam manually via package-list-packages, edited my .emacs file per the org-roam documentation, then opened a new instance of Emacs.

From the command line I can run sqlite3 and it takes me into a SQL REPL. But in Emacs, if I run (executable-find "sqlite3") nothing happens, as if it can’t find the executable. (Running that is suggested in the org-roam docs, here.) On the other hand, the same thing (nothing) happens if I evaluate (executable-find "grep") (which is also installed) or (executable-find "fishbreath") (which is not a thing). So maybe Emacs just doesn’t know where anything is?

Debugger entered--Lisp error: (error "No EmacSQL SQLite binary available, aborting")
  signal(error ("No EmacSQL SQLite binary available, aborting"))
  error("No EmacSQL SQLite binary available, aborting")
  emacsql-sqlite-ensure-binary()
  byte-code("\3001\n\0\301 \210\3020\207\303\304\002\"\210\305\207" [(debug error) emacsql-sqlite-ensure-binary t message "Org-roam initialization: %S" nil] 4)
  (defconst org-roam-db--sqlite-available-p (byte-code "\3001\n\0\301 \210\3020\207\303\304\002\"\210\305\207" [(debug error) emacsql-sqlite-ensure-binary t message "Org-roam initialization: %S" nil] 4))
  require(org-roam-db)
  byte-code("\300\301!\210\300\302!\210\300\303!\210\300\304!\210\300\305!\210\300\306!\210\300\307!\210\300\310!\210\300\311!\210\300\312!\210\300\313!\210\300\314!\210\300\315!\210\300\316!\210\300\317!\210\300\320!\210\300\321!\210\300\322\323\324#\210\325\326\323\327\330\301\331\332\333\334\333\335&\013\210\325\336\323\337\330\326\330\340&\007\210\341\342\343\344\345DD\346\347\350\330\326&\007\210\341\351\343\344\352DD\353\347\354\330\326&\007\210\341\355\343\344\356DD\357\347\360\330\326&\007\210\341\361\343\344\362DD\363\347\360\330\326&\007\210\341\364\343\344\365DD\366\347\367\330\326&\007\210\341\370\343\344\371DD\372\347\373\330\326&\007\210\341\374\343\344\375DD\376\347\377%\207" [require org org-element ob-core dash s f cl-lib seq org-roam-compat org-roam-macs org-roam-db org-roam-buffer org-roam-capture org-roam-graph org-roam-completion org-roam-dailies org-roam-doctor org-ref nil t custom-declare-group org-roam "Roam Research replica in Org-mode." :group :prefix "org-roam-" :link (url-link :tag "Github" "https://github.com/org-roam/org-roam") (url-link :tag "Online Manual" "https://org-roam.github.io/org-roam/manual/") org-roam-faces "Faces used by Org-roam." faces custom-declare-variable org-roam-directory funcall function #f(compiled-function () #<bytecode 0x11fb741>) "Default path to Org-roam files.\n\nAll Org files, at any level of nesting, are considered part of the Org-roam." :type directory org-roam-link-title-format #f(compiled-function () #<bytecode 0x11fb515>) "The formatter used when inserting Org-roam links that use their title.\nFormatter may be a function that takes title as its only argument." (choice (string :tag "String Format" "%s") (function :tag "Custom function")) org-roam-encrypt-files #f(compiled-function () #<bytecode 0x1231d21>) "Whether to encrypt new files.  If true, create files with .gpg extension." boolean org-roam-verbose ...] 12)
  org-roam-mode()
  run-hooks(after-init-hook delayed-warnings-hook)
  command-line()
  normal-top-level()

Do you maintain your Emacs config manually or declaratively?

If you do it declaratively, you should be able to (add-to-list 'exec-path "${sqlite3}/bin") from wherever you generate your init.el.

Procedurally, I guess? I don’t seem to have an init.el file. I maintain a .emacs file in my home folder, just like I did on Ubuntu before NixOS. I tried adding the line you suggested to it, and still get the same error.

According to @jethrokuan, the problem is (if I understand him) that org-roam recently changed and will require an override until nixpkgs catches up. I’m currently trying to understand overlays; maybe once I do I can act on his suggestion.

I don’t declaratively install my Emacs packages, and having sqlite3 in my environment.systemPackages is enough for me to get things working. I’m also on NixOS.

Weird!

When I put sqlite3 in environment.systemPackages, rebuilding gives me an error: undefined variable 'sqlite3' at /etc/nixos/packages.nix:81:5. If I just specify sqlite, though, I can use it just fine – and it installs sqlite3. (In fact it leaves sqlite undefined at the command prompt.) But you’re able to put sqlite3 in environment.systemPackages? Are you using NixOS 20.03 stable?

You said you don’t install Emacs packages declaratively, and that Emacs is able to find sqlite3 and run org-roam. So I just tried removing emacsql-sqlite3 from my emacs.nix file (but leaving everything else) and installing org-roam and all its Emacs dependencies manually. I left sqlite in my environment.systemPackages declarations, so that sqlite3 would remain installed. Then I rebuilt NixOS, manually uninstalled emacssql and emacssql-sqlite and org-roam via package-list-packages, and then installing org-roam procedurally within Emacs. (That causes Emacs to install emacsql-sqlite3 as a dependency.)

I got the error below. So then I uninstalled those things procedurally and reobooted and tried again, just in case for some reason that would matter. I got the same error:

Debugger entered--Lisp error: (error "No EmacSQL SQLite binary available, aborting")
  signal(error ("No EmacSQL SQLite binary available, aborting"))
  error("No EmacSQL SQLite binary available, aborting")
  emacsql-sqlite-ensure-binary()
  byte-code("\3001\n\0\301 \210\3020\207\303\304\002\"\210\305\207" [(debug error) emacsql-sqlite-ensure-binary t message "Org-roam initialization: %S" nil] 4)
  (defconst org-roam-db--sqlite-available-p (byte-code "\3001\n\0\301 \210\3020\207\303\304\002\"\210\305\207" [(debug error) emacsql-sqlite-ensure-binary t message "Org-roam initialization: %S" nil] 4))
  require(org-roam-db)
  apply(require org-roam-db)
  byte-compile-file-form-require((require (quote org-roam-db)))
  byte-compile-file-form((require (quote org-roam-db)))
  #f(compiled-function (form) #<bytecode 0x44f40d>)((require (quote org-roam-db)))
  byte-compile-recurse-toplevel((require (quote org-roam-db)) #f(compiled-function (form) #<bytecode 0x44f40d>))
  byte-compile-toplevel-file-form((require (quote org-roam-db)))
  #f(compiled-function (inbuffer) #<bytecode 0x48dbe1>)(#<buffer  *Compiler Input*>)
  byte-compile-from-buffer(#<buffer  *Compiler Input*>)
  byte-compile-file("/home/jeff/.emacs.d/elpa/org-roam-1.1.1/org-roam-graph.el" nil)
  byte-recompile-file("/home/jeff/.emacs.d/elpa/org-roam-1.1.1/org-roam-graph.el" t 0)
  #f(compiled-function () #<bytecode 0x1818ff5>)()
  byte-recompile-directory("/home/jeff/.emacs.d/elpa/org-roam-1.1.1" 0 t)
  package--compile(#s(package-desc :name org-roam :version (1 1 1) :summary "Roam Research replica with Org-mode" :reqs ((emacs (26 1)) (dash (2 13)) (f (0 17 2)) (s (1 12 0)) (org (9 3)) (emacsql (3 0 0)) (emacsql-sqlite (1 0 0))) :kind nil :archive nil :dir "/home/jeff/.emacs.d/elpa/org-roam-1.1.1" :extras ((:url . "https://github.com/org-roam/org-roam") (:maintainer "Jethro Kuan" . "jethrokuan95@gmail.com") (:authors ("Jethro Kuan" . "jethrokuan95@gmail.com")) (:keywords "org-mode" "roam" "convenience") (:commit . "cce2db8b5a2c1f1258bcb35f4a3241067e4f950e")) :signed nil))
  package-unpack(#s(package-desc :name org-roam :version (1 1 1) :summary "Roam Research replica with Org-mode" :reqs ((emacs (26 1)) (dash (2 13)) (f (0 17 2)) (s (1 12 0)) (org (9 3)) (emacsql (3 0 0)) (emacsql-sqlite (1 0 0))) :kind tar :archive "melpa-stable" :dir nil :extras ((:commit . "cce2db8b5a2c1f1258bcb35f4a3241067e4f950e") (:keywords "org-mode" "roam" "convenience") (:authors ("Jethro Kuan" . "jethrokuan95@gmail.com")) (:maintainer "Jethro Kuan" . "jethrokuan95@gmail.com") (:url . "https://github.com/org-roam/org-roam")) :signed nil))
  package-install-from-archive(#s(package-desc :name org-roam :version (1 1 1) :summary "Roam Research replica with Org-mode" :reqs ((emacs (26 1)) (dash (2 13)) (f (0 17 2)) (s (1 12 0)) (org (9 3)) (emacsql (3 0 0)) (emacsql-sqlite (1 0 0))) :kind tar :archive "melpa-stable" :dir nil :extras ((:commit . "cce2db8b5a2c1f1258bcb35f4a3241067e4f950e") (:keywords "org-mode" "roam" "convenience") (:authors ("Jethro Kuan" . "jethrokuan95@gmail.com")) (:maintainer "Jethro Kuan" . "jethrokuan95@gmail.com") (:url . "https://github.com/org-roam/org-roam")) :signed nil))
  mapc(package-install-from-archive (#s(package-desc :name emacsql :version (3 0 0) :summary "high-level SQL database front-end" :reqs ((emacs (25 1))) :kind tar :archive "melpa-stable" :dir nil :extras ((:commit . "8c5f095458aa37e4146b80d9319ee63571734127") (:authors ("Christopher Wellons" . "wellons@nullprogram.com")) (:maintainer "Christopher Wellons" . "wellons@nullprogram.com") (:url . "https://github.com/skeeto/emacsql")) :signed nil) #s(package-desc :name emacsql-sqlite :version (3 0 0) :summary "EmacSQL back-end for SQLite" :reqs ((emacs (25 1)) (emacsql (2 0 0))) :kind tar :archive "melpa-stable" :dir nil :extras ((:commit . "8c5f095458aa37e4146b80d9319ee63571734127") (:authors ("Christopher Wellons" . "wellons@nullprogram.com")) (:maintainer "Christopher Wellons" . "wellons@nullprogram.com") (:url . "https://github.com/skeeto/emacsql")) :signed nil) #s(package-desc :name org-roam :version (1 1 1) :summary "Roam Research replica with Org-mode" :reqs ((emacs (26 1)) (dash (2 13)) (f (0 17 2)) (s (1 12 0)) (org (9 3)) (emacsql (3 0 0)) (emacsql-sqlite (1 0 0))) :kind tar :archive "melpa-stable" :dir nil :extras ((:commit . "cce2db8b5a2c1f1258bcb35f4a3241067e4f950e") (:keywords "org-mode" "roam" "convenience") (:authors ("Jethro Kuan" . "jethrokuan95@gmail.com")) (:maintainer "Jethro Kuan" . "jethrokuan95@gmail.com") (:url . "https://github.com/org-roam/org-roam")) :signed nil)))
  package-download-transaction((#s(package-desc :name emacsql :version (3 0 0) :summary "high-level SQL database front-end" :reqs ((emacs (25 1))) :kind tar :archive "melpa-stable" :dir nil :extras ((:commit . "8c5f095458aa37e4146b80d9319ee63571734127") (:authors ("Christopher Wellons" . "wellons@nullprogram.com")) (:maintainer "Christopher Wellons" . "wellons@nullprogram.com") (:url . "https://github.com/skeeto/emacsql")) :signed nil) #s(package-desc :name emacsql-sqlite :version (3 0 0) :summary "EmacSQL back-end for SQLite" :reqs ((emacs (25 1)) (emacsql (2 0 0))) :kind tar :archive "melpa-stable" :dir nil :extras ((:commit . "8c5f095458aa37e4146b80d9319ee63571734127") (:authors ("Christopher Wellons" . "wellons@nullprogram.com")) (:maintainer "Christopher Wellons" . "wellons@nullprogram.com") (:url . "https://github.com/skeeto/emacsql")) :signed nil) #s(package-desc :name org-roam :version (1 1 1) :summary "Roam Research replica with Org-mode" :reqs ((emacs (26 1)) (dash (2 13)) (f (0 17 2)) (s (1 12 0)) (org (9 3)) (emacsql (3 0 0)) (emacsql-sqlite (1 0 0))) :kind tar :archive "melpa-stable" :dir nil :extras ((:commit . "cce2db8b5a2c1f1258bcb35f4a3241067e4f950e") (:keywords "org-mode" "roam" "convenience") (:authors ("Jethro Kuan" . "jethrokuan95@gmail.com")) (:maintainer "Jethro Kuan" . "jethrokuan95@gmail.com") (:url . "https://github.com/org-roam/org-roam")) :signed nil)))
  package-install(#s(package-desc :name org-roam :version (1 1 1) :summary "Roam Research replica with Org-mode" :reqs ((emacs (26 1)) (dash (2 13)) (f (0 17 2)) (s (1 12 0)) (org (9 3)) (emacsql (3 0 0)) (emacsql-sqlite (1 0 0))) :kind tar :archive "melpa-stable" :dir nil :extras ((:commit . "cce2db8b5a2c1f1258bcb35f4a3241067e4f950e") (:keywords "org-mode" "roam" "convenience") (:authors ("Jethro Kuan" . "jethrokuan95@gmail.com")) (:maintainer "Jethro Kuan" . "jethrokuan95@gmail.com") (:url . "https://github.com/org-roam/org-roam")) :signed nil) dont-select)
  package-menu--perform-transaction((#s(package-desc :name org-roam :version (1 1 1) :summary "Roam Research replica with Org-mode" :reqs ((emacs (26 1)) (dash (2 13)) (f (0 17 2)) (s (1 12 0)) (org (9 3)) (emacsql (3 0 0)) (emacsql-sqlite (1 0 0))) :kind tar :archive "melpa-stable" :dir nil :extras ((:commit . "cce2db8b5a2c1f1258bcb35f4a3241067e4f950e") (:keywords "org-mode" "roam" "convenience") (:authors ("Jethro Kuan" . "jethrokuan95@gmail.com")) (:maintainer "Jethro Kuan" . "jethrokuan95@gmail.com") (:url . "https://github.com/org-roam/org-roam")) :signed nil)) nil)
  package-menu-execute()
  funcall-interactively(package-menu-execute)
  call-interactively(package-menu-execute nil nil)
  command-execute(package-menu-execute)

Hey @JeffreyBenjaminBrown, apologies I meant sqlite. The Elisp error message suggests to me that you’re on an old version of org-roam that used emacsql-sqlite (that uses a compiled executable), compared to emacsql-sqlite3, which looks for an existing binary in the path. You’ll have to bump the versions in Nixpkgs, or use Nix community’s emacs overlay.

Woohoo! Version 1.2 installs! I didn’t even have to get the overlay working. Which is awesome because I cannot for the life of me understand NixOS overlays. Now I don’t have to use the Docker container!

Had the same problem, it seems that I needed a C compiler.
Adding GCC to the environment.systemPackages solved the problem for me.

2 Likes

Thank you very much, tried everything, but it turned out that there was no way for it compile since i didn’t have gcc or anything…