Lxd init: libdqlite.so.0 not found

Help lxd init fails. I compiled lxd from source following the guide. lxd init is failing because the system can not find libdqlite.so.0. even though libsqlite3-0 and sqlite are installed, the library exists, the symbollic link in the path exists, etc. Per LXD v3.3: error while loading shared libraries: libdqlite.so.0: cannot open shared object file: No such file or directory · Issue #4865 · lxc/lxd · GitHub I’ve edited .bashrc and .profile but have not yet edit /etc/environment because even when lxd init is run from the same path as the library it fails to find the library.

Error: lxd: error while loading shared libraries: libdqlite.so.0: cannot open shared object file: No such file or directory

sudo lxd init can’t see lxd because sudo whereis lxd fails. ie sudo path is different than user path.
Therefore I run lxd init as follows:
$ sudo --preserve-env=PATH,LD_LIBRARY_PATH env lxd init

ENV VARS

$ echo $PATH
   /home/userid/opt/anaconda/bin:
   /home/userid/opt/anaconda/condabin:
   /usr/local/sbin:/usr/local/bin:
   /usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:
   /snap/bin:/home/userid/go/bin
$ sudo echo $PATH
   /home/userid/opt/anaconda/bin:
   /home/userid/opt/anaconda/condabin:
   /usr/local/sbin:/usr/local/bin:
   /usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:
   /snap/bin:/home/userid/go/bin
$ sudo echo $LD_LIBRARY_PATH 
   /home/userid/go/deps/dqlite/.libs/:
   /home/userid/go/deps/raft/.libs/:
   /home/userid/opt/lxd-5.6/vendor/raft/.libs/:
   /home/userid/opt/lxd-5.6/vendor/dqlite/.libs/
$ echo $LD_LIBRARY_PATH 
   /home/userid/go/deps/dqlite/.libs/:
   /home/userid/go/deps/raft/.libs/:
   /home/userid/opt/lxd-5.6/vendor/raft/.libs/:
   /home/userid/opt/lxd-5.6/vendor/dqlite/.libs/

Whereis the library? (note same result if user or sudo)

$ ldconfig -p | grep -E 'sqlite|dqlite' 
	libsqlite3.so.0 (libc6,x86-64) => /lib/x86_64-linux-gnu/libsqlite3.so.0
	libsqlite3.so (libc6,x86-64) => /lib/x86_64-linux-gnu/libsqlite3.so
$ ls -lah ~/go/deps/dqlite/.libs
drwxrwxr-x  2 userid userid 4.0K Oct 13 08:31 .
drwxrwxr-x 14 userid userid 4.0K Oct 14 07:55 ..
-rw-rw-r--  1 userid userid 2.0M Oct 13 08:31 libdqlite.a
lrwxrwxrwx  1 userid userid   15 Oct 13 08:31 libdqlite.la -> ../libdqlite.la
-rw-rw-r--  1 userid userid 1.1K Oct 13 08:31 libdqlite.lai
lrwxrwxrwx  1 userid userid   18 Oct 13 08:31 libdqlite.so -> libdqlite.so.0.0.1
lrwxrwxrwx  1 userid userid   18 Oct 13 08:31 libdqlite.so.0 -> libdqlite.so.0.0.1
-rwxrwxr-x  1 userid userid 1.1M Oct 13 08:31 libdqlite.so.0.0.1

This page may help installing from source:

That is the page I was following. Source builds but won’t run due to not respecting path or not recognizing valid file. Hoping someone else has ideas for how to fix.

With respect to building source

  • I did not install the extra storage drivers
  • I did grab go from outside the package tree from Downloads - The Go Programming Language to avoid issues with “build github.com/lxc/lxd/lxc-to-lxd: cannot load io/fs: malformed module path “io/fs”: missing dot in first path element” starting with go v1.16, which is an unstated lxd version dependency.
  • the multiple paths because I tried both git pull and 5.6 tarball version when I was having issues with lxd building. I might consider this an issue if it said the file was bad, but it says the library file does not exist.

Sounds to me like you’re not running LXD with the correct env vars, e.g.

sudo -E PATH=${PATH} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} $(go env GOPATH)/bin/lxd 

okay that worked, sort of. I have a different error now to investigate: Error: Failed to connect to local LXD: Get “http://unix.socket/1.0”: dial unix /var/lib/lxd/unix.socket: connect: no such file or directory

Re original error: Curious why --preserve-env was not working to accomplish the same thing, or why running lxd from the folder of the library not found didn’t work.

The new error set following running the two commands I need to investigate are …
$ sudo -E PATH=${PATH} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} $(go env GOPATH)/bin/lxd
WARNING[2022-10-18T09:48:06-05:00] - Couldn’t find the CGroup blkio.weight, disk priority will be ignored
WARNING[2022-10-18T09:48:06-05:00] - Couldn’t find the CGroup memory swap accounting, swap limits will be ignored
WARNING[2022-10-18T09:48:06-05:00] Firewall failed to detect any compatible driver, falling back to “xtables” (but some features may not work as expected due to: Backend command “ebtables” is an nftables shim)
WARNING[2022-10-18T09:48:08-05:00] Failed to initialize fanotify, falling back on fsnotify err=“Failed to initialize fanotify: invalid argument”
^C
$ sudo -E PATH=${PATH} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} $(go env GOPATH)/bin/lxd init
Error: Failed to connect to local LXD: Get “http://unix.socket/1.0”: dial unix /var/lib/lxd/unix.socket: connect: no such file or directory

Runing lxd builded from sources fails points to maybe this is not an error to worry about. Seems odd behavior but okay I’ll investigate and update later.

Tomp, I appreciate the help.

I apologize for being dense. I got further and I think I understand at least partially where I went wrong.

In the install from source [R1] the last command is to start the daemon. After all the attempts to get source to build failing, at some point I overlooked this step and reverted to the getting started cli instructions [R2] which start with lxd init. Without the daemon, lxd init was giving odd errors. Add to that failure the path environmental variable inconsistency vs the directions.

What “worked”:
$ sudo -E PATH=${PATH} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} $(go env GOPATH)/bin/lxd --group sudo
$ sudo -E PATH=${PATH} LD_LIBRARY_PATH=${LD_LIBRARY_PATH} $(go env GOPATH)/bin/lxd init

Thank you again for the help, I’ll start a new thread for my next set of unrelated questions.

References

  1. Installing LXD - LXD documentation
  2. Linux Containers - LXD - Getting started
1 Like