Update SQLite to 3.40.1 or later (can't update)

I get this warning message after installing 2024.8.3.

However when I run

sudo apt install sqlite3

It says

sqlite3 is already the newest version (3.37.2-2ubuntu0.3)

Does anyone know what I should do?

1 Like

Update Ubuntu first?

I have Linux Mint 21.3, which is based on Ubuntu 22.04.

Many users will be on a 22.04 based system, which receives LTS (Long-Term Support) until 2027. One wonders why this wasn’t good enough, it includes v3.37.2 of sqlite

I’ve set the ā€œCritical Repair promptā€ to ignored for now.

@bdraco , as you seem to be involved in the upcoming SQLite dependency version bump, could you provide insights?

I’m surprised about this warning in general. The SQLite client is pulled in via pip, not as an OS-provided client, right? (e.g., I don’t have any sqlite apt packages installed in my operating system).

If that’s so, then it is out-of-scope for the Home Assistant administrator to take care of updating SQLite. Instead, it will take place via an upcoming Home Assistant update.

We would need someone to make a long term commitment to testing and maintaining older versions until 2027, and dealing with writing any manual migrations that can’t be done on all versions to realistically be able to support old versions to make that happen.

SQLite is provided by the operating system in almost all cases. Python is generally linked against the SQLite provided by the operating system unless you’ve compiled your own custom python, with its statically linked to a different version

1 Like

I didn’t know that. Thank you for this clarification.

My Home Assistant Core installation runs on Ubuntu 22.04.4 LTS jammy (Raspberry Pi 4B).

Because Ubuntu 22.04’s apt package archives only provide Python 3.10, and because previous HA upgrades bumped the minimum Python version requirements to Python 3.12 currently (2024.8.x), I leverage Python3.12 from the deadsnakes PPA.

Assuming I understand the deadsnakes Python3.12 build process correctly, it uses Ubuntu 22.04’s ā€œoriginalā€ libsqlite3-dev, which will probably stay at version 3.37.2.

Confirming command:

$ python3.12 -c 'import sqlite3;print(sqlite3.sqlite_version)'
3.37.2

# learned from https://discuss.python.org/t/will-sqlite3-be-updated-in-the-standard-library-to-address-fixed-cvss-vulnerabilities/48629

So in case the proposed amendment doesn’t make it, us Ubuntu 22.04 homelab users will have a long weekend in February 2025, or just shrug it off and peak/sunset at Home Assistant 2025.01.

1 Like

I’ve realized I made a mistake to choose an LTS OS for my Home Assistant. I’m going to be migrating off of Ubuntu LTS personally. HA bumps dependencies way too quickly to work with an LTS OS properly. If you have to make it work with Deadsnakes (as I currently am as well) it defeats the purpose of LTS entirely.

1 Like

Does anyone know which is the ā€œcanonicalā€ linux distro the devs are chasing with these version upgrades?
I have been running Raspbian (on RPi 3B+), but this seems like a futile attempt for past several years.

1 Like

Is there a way to set which sqlite is used? I’ve got sqlite 3.47 installed in /usr/local/bin, and this is the default one on the command line:

>sudo su - homeassistant
$ sqlite3 -version
3.47.2 2024-12-07 20:39:59 2aabe05e2e8cae4847a802ee2daddc1d7413d8fc560254d93ee3e72c14685b6c (64-bit)

However, the Recorder code seems to use the 3.37 version installed at /usr/bin/sqlite3. I’d much rather point HA at the local version than change my system sqlite. I can’t see any way to do this in the Recorder docs (Recorder - Home Assistant) - they only allow specifying a DB via the url schema.

Small update on this - I’ve managed to get the installed python to work with sqlite3:

(homeassistant) homeassistant@xxx:/srv/homeassistant$ python3
Python 3.13.1 (main, Dec  4 2024, 08:54:14) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import _sqlite3
>>> _sqlite3.sqlite_version
'3.47.2'

However, this isn’t picked up by homeassistant - anything I would need to do?

(for anyone else trying to do this, I’ve installed from source (SQLite Download Page) into /usr/local, and then added this to the bin/activate script in /srv/homeassistant:

...
export LD_LIBRARY_PATH=/usr/local/lib
1 Like

OK, I now have things working!

Procedure:

...
Environment="LD_LIBRARY_PATH=/usr/local/lib"

Now, I’ve got HA running happily on Ubuntu 22.04.5 LTS.

6 Likes

Thank you for pulling this write up together! I’m up and running on SQLite 3.48 on Ubuntu 20.04 LTS!

1 Like

Another big THANK YOU! Had tried many ways and quit until it had to happen. Up and running!

1 Like

This did not work for me. Python ignores LD_LIBRARY_PATH for security reasons. I am surprised it worked on your system if you use HA core.

To make it work on core, I had to compile a local recent version of sqlite3, like you did. Then, I had to recompile my python executable used for the HA virtual environment and tweak the Makefile after configuration to add this flag to the link: -Wl,-rpath=/usr/local/lib. Add this to the MODULE__SQLITE3_LDFLAGS= line in the makefile. This will instruct the python executable to look in your /usr/local/lib directory for the sqlite3 .so library. That’s it.

In the file site-packages/homeassistant/components/recorder/util.py I changed the line

MIN_VERSION_SQLITE = _simple_version(ā€œ3.40.1ā€)

into

MIN_VERSION_SQLITE = _simple_version(ā€œ3.37.2ā€)

Thats it. No idea why they think they need 3.40

While the current code doesn’t rely on any features from newer versions yet, part of our process is to give everyone advance notice before making such changes. Once we start using newer features, as we plan to, you could risk ending up with a broken database if you’re not aligned with the supported version.

The minimum version 3.40 was introduced before it was necessary and without recognizing that for many systems 3.40 is not available.