Bug in Anki 25.02: Bundled Qt6 libraries not found due to incorrect LD_LIBRARY_PATH call in launcher (+PROPOSED FIX)

Installing Anki 25.02 via included install script on Ubuntu 24.04.2 then running via “anki” generates the following error:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "aqt", line 63, in <module>
  File "aqt.gui_hooks", line 11, in <module>
  File "_aqt.hooks", line 18, in <module>
  File "aqt.qt", line 22, in <module>
  File "aqt.qt.qt6", line 12, in <module>
ImportError: /usr/lib/x86_64-linux-gnu/libQt6Core.so.6: version `Qt_6.6' not found (required by /usr/local/share/anki/lib/PyQt6/QtCore.abi3.so)

Anki bundles its own Qt6 libraries (which include the required Qt_6.6 symbols) inside the installation directory (e.g., /usr/local/share/anki/lib/PyQt6/Qt6/lib). However, the launcher script sets LD_LIBRARY_PATH as follows:

export LD_LIBRARY_PATH="/usr/local/share/anki/lib:$LD_LIBRARY_PATH"

But qt 6.6 is bundled in a deeper subdirectory inside of anki/lib, so the dynamic linker just looks for it in system directories, completely bypassing the module’s RUNPATH ($ORIGIN/Qt6/lib)

So the system Qt6 libraries are loaded (6.4.2 on Ubuntu) leading to the error.

Fix is easy, just change the launcher script to include a pointer to the bundled PyQt6 folder as well as the broader lib folder:

export LD_LIBRARY_PATH="/usr/local/share/anki/lib/PyQt6/Qt6/lib:/usr/local/share/anki/lib:$LD_LIBRARY_PATH"

Users can apply this fix independently with:

sudo sed -i 's|/usr/local/share/anki/lib:|/usr/local/share/anki/lib/PyQt6/Qt6/lib:/usr/local/share/anki/lib:|' /usr/local/bin/anki

A long time ago I had developer access and would have just put this on github as a pull request but it’s been a few years since I’ve had any time to contribute.

Can one of the devs fold this in? It’s a pretty simple patch but it breaks the ability of nontechnical users to use the program at all without rolling back several versions.

I guess it’s specified in the launcher script and packaging process rather than the code itself… not quite sure where those changes start.

Is this already addressed by anything in the Platform Notes? Install & Upgrade - Anki Manual

No, I don’t think so.

But it’s weird that OP had to do this in ubuntu. Ubuntu is based on Debian and the install script works without issues on Debian (sid). Anki runs fine afterwards, too.

Maybe it’s something specific to ubuntu for some reason? Or regarding OPs setup?

1 Like

Ah, great to hear this might be unique, didn’t realize.

So I’m testing on a clean install of Ubuntu 24.04.1 using virtualbox. I installed third party additions and ran apt update && apt upgrade, then just downloaded the latest and installed it using this command:

wget -O anki-25.02-linux-qt6.tar.zst https://github.com/ankitects/anki/releases/download/25.02/anki-25.02-linux-qt6.tar.zst && tar -I zstd -xf anki-25.02-linux-qt6.tar.zst && cd anki-25.02-linux-qt6 && sudo ./install.sh

then I get this error, slightly different than my first:

...
Install complete. Type 'anki' to run.
vm-user@vm-user-VirtualBox:~/anki-25.02-linux-qt6$ anki
Anki starting...
Initial setup...
Starting Anki 25.02...
Wayland support is disabled by default due to bugs:
https://github.com/ankitects/anki/issues/1767
You can force it on with an env var: ANKI_WAYLAND=1
Qt warning: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin. 
Qt info: Could not load the Qt platform plugin "xcb" in "" even though it was found. 
Qt fatal: This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: xcb, wayland, eglfs, offscreen, vkkhrdisplay, minimal, wayland-egl, minimalegl, vnc, linuxfb.
 
Aborted (core dumped)

If I run

sudo apt install libxcb-cursor0

It fixes this issue and anki runs.

I wonder if having other sources of pyqt6 from other applications caused this… still investigating to see if i can reproduce it fully on a clean VM

Oh, I see. In that case Danika_Dakika was right after all – it is already covered in Requirements from the link above. My debian sid vm has these dependencies installed already since I test and develop anki here.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.