Need support for building / packaging

I try to assemble a new debian/ubuntu deb package. The current package from their repos is version 2.1.15 and goes back to 2020.

At first, I re-packed the binary build and published it in a ppa. This is sub-optimal because it’s not best practice and there may also be license issues.

So, I’ve set up a docker environment for building anki (including cargo and ninja). But I can’t find any information about how to build it. I found the run script in the repo root directory, and installed everything necessary for getting anki running (the last line in the script), but even then I can’t find a generated anki binary file.

So, starting from here, which steps are necessary for finishing a complete anki build? for version 24.04beta1 and following, and maybe also 23.12.1.

So, my goal at first is a positive result for find -name anki -executable -type f

Thanks

2 Likes

Updating anki is not trivial because of their build system.

Anki is a great software, but unfortunately it is quite difficult to install on Linux systems. Almost all packages on major distros are by now years out of date or kicked out, because Anki changed its build systems so many times, that the existing package maintainers simply dropped it

With so many distros falling hopelessly behind, let’s face it: Anki has a packaging problem.

And here we are: Due to Anki’s security issue of its build process (can’t be compiled offline with reasonable afford), now Anki has been kicked out of the popular Linux distribution Fedora.

FWIW I had a quick look at recompiling anki and it’s become a pretty big monster: some python, rust (python-rust built with maturin), nodejs…

I looked at anki >= 2.1.17 a while ago (and now again) and I concur: getting it updated in Fedora will be very complicated or probably even impossible.

They are also now building Anki using their own Rust program (called maturin). This is making packaging the newer releases for Debian significantly challenging, as it require liaising with the Rust team and learning a whole new packaging environment. Rust has lots of little modules (“crates”), each of which is packaged separately, and the version dependencies are pretty horrendous.

can anyone tell me why anki is implemented so poorly in its core functionality?

You are fighting an uphill battle.

All attempts were dropped because of the previous build system, Bazel

Now Anki uses Ninja which is way easier to build, but requires rewriting Anki build system compared to 2.1.15

With the new new new build system, Anki is feasible to build fully offline with a moderate amount of patching.

Build examples of Anki latest (23.12.1)

hope you have success, I love Anki and Linux alike

1 Like

Thanks, this is a perfect starting point.

I saw the other posts about previous versions, namely the one from the debian bug reporter (can’t provide links here). But seeing a running up-to-date version running by simply calling ./run gives me hope.

I think the provided links are all I needed to finish that work.

1 Like

Anki only have support for x86_64, so the Aarch64/Arm version will still use the previous 2.1.15 version

upstream only supports 64-bit architectures

If it is possible, can the Alpine solution be implemented (the commit msg indicates support for 23.12.1 in aarch64, but still unsure)?

Or is it better to wait for an official arm version of Anki?

How was the anki binary generated in anki-24.04-linux-qt5.tar.zst? I can only find ninja wheels target which generates two *.whl files

It’s covered in the docs/ folder.

Ok, current progress:

  1. Packing the binary distribution was done already before writing this ticket. not a big deal, but not the way to go for ubuntu
  2. Packing the sources was somehow easy, after I discovered how to build the bundle. Unfortunately, this process downloads a lot of files, but ubuntu buildserver work 100% offline, so this is not a solution for something official.
  3. Trying to pre-download these files seems very complicated. There is cargo vendor, but there are also 4 extra files to download, multiple git repos, and multiple python venvs. Right now, all of them are working except the python venvs, because there I didn’t find a way yet to change the pip install command to use the pre-downloaded files. the source package has a size of more than 150mb already bytheway.

So I think I will close with the binary distribution as soon the 24 release is out.

1 Like

I have no rust or python experience. Trying to set this up on WSL2 running Ubuntu on Windows 10, I first got this error:

thread ‘main’ panicked at build/runner/src/build.rs:82:39:
ninja not installed: Os { code: 7, kind: ArgumentListTooLong, message: “Argument list too long” }
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
Finished dev [unoptimized + debuginfo] target(s) in 0.50s
Running out/rust/debug/configure
Finished release [optimized] target(s) in 0.67s
thread ‘main’ panicked at build/runner/src/build.rs:82:39:
ninja not installed: Os { code: 7, kind: ArgumentListTooLong, message: “Argument list too long” }
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

With the comments here Ankiweb forum @ /building-from-source-fails-at-rust-config/34204 I ran

tools/clean
tools/install-n2
./run

which really seems to bring some progress but ended with this importError:

n2: ran 72 tasks, now up to date

Build succeeded in 1026.00s.
Traceback (most recent call last):
File “/home/user/webworks/digitalcards/tools/run.py”, line 11, in
import aqt
File “/home/user/webworks/digitalcards/qt/aqt/init.py”, line 56, in
from aqt import gui_hooks
File “/home/user/webworks/digitalcards/qt/aqt/gui_hooks.py”, line 11, in
from _aqt.hooks import *
File “/home/user/webworks/digitalcards/out/qt/_aqt/hooks.py”, line 18, in
from aqt.qt import QDialog, QEvent, QMenu, QModelIndex, QWidget, QMimeData
File “/home/user/webworks/digitalcards/qt/aqt/qt/init.py”, line 20, in
from .qt6 import *
File “/home/user/webworks/digitalcards/qt/aqt/qt/qt6.py”, line 15, in
from PyQt6.QtGui import * # type: ignore[misc,assignment]
ImportError: libEGL.so.1: cannot open shared object file: No such file or directory

What else do I need to do at this point to get it running? Thank you!

No testing has been done on WSL. Anki’s Windows build is done directly on Windows, and requires Visual Studio.

The official Linux build works on WSL by the way.

Thanks for the responses. Is the github repo only for Windows? I thought it’s the web backend that foundeamentally powers the rest of the android, iOS, etc build.

See docs/