Anki: cannot open shared object file libfontconfig.so.1

My first attempt at a snap is packaging up Anki.

It offers a compiled version of Anki that bundles most of the required libraries so I’m simply using the dump plugin to extract the tar file, and then running the binary.

First I had an UTF-8 issue so I’ve tweaked the LC_ALL environment variable, which fixes that.

However when I run the snap I get the following error message: ImportError: libfontconfig.so.1: cannot open shared object file: No such file or directory. I’ve tried adding fontconfig to stage-packages and the library seems to be in LD_LIBRARY_PATH but I still get the same error.

I’ve been struggling with this for the last few hours so any help would be appreciated!

name: anki
version: '2.0.47'
summary: Anki - powerful, intelligent flashcards
description: |
  Anki is a program which makes remembering things easy. Because it\'s a lot
  more efficient than traditional study methods, you can either greatly
  decrease your time spent studying, or greatly increase the amount you learn.
grade: stable
confinement: devmode

apps:
  anki:
    command: env LC_ALL=C.UTF-8 $SNAP/bin/anki
    desktop: "anki.desktop"
    plugs: [pulseaudio, home]

parts:
  anki:
    source: "https://apps.ankiweb.net/downloads/current/anki-2.0.47-amd64.tar.bz2"
    plugin: dump
    stage-packages:
      - fontconfig
1 Like

Hey, first of all, thanks a lot for snapping anki, I’d really like to see it as a snap!

That’s an odd issue indeed! It looks to me like there is some issue either with Anki’s PyInstaller configuration or PyInstaller as I assume it should bundle those libraries.

As you said, the PyInstaller module loader doesn’t seem to respect LD_LIBRARY_PATH. I managed to workaround it by creating a symlink like this:

name: anki
version: '2.0.47'
summary: Anki - powerful, intelligent flashcards
description: |
  Anki is a program which makes remembering things easy. Because it\'s a lot
  more efficient than traditional study methods, you can either greatly
  decrease your time spent studying, or greatly increase the amount you learn.
grade: stable
confinement: devmode

apps:
  anki:
    command: bin/anki
    desktop: "anki.desktop"
    plugs: [pulseaudio, home]
    environment:
      LC_ALL: C.UTF-8

parts:
  anki:
    source: "https://apps.ankiweb.net/downloads/current/anki-2.0.47-amd64.tar.bz2"
    plugin: dump
    stage-packages:
      - libfontconfig1
  fix-fontconfig:
    plugin: nil
    install: |
      mkdir -p $SNAPCRAFT_PART_INSTALL/bin/
      ln -s /snap/anki/current/usr/lib/x86_64-linux-gnu/libfontconfig.so.1 \
            $SNAPCRAFT_PART_INSTALL/bin/libfontconfig.so.1
    after: [anki]

but this is a rather hacky solution and I also immediately ran into the next missing library:
ImportError: libSM.so.6: cannot open shared object file: No such file or directory.

Which makes me think that it might actually be better to build anki from source? Anyway, I think this can be considered a packaging bug of Anki given the bundle is missing those libraries (?) – please correct me if I’m wrong with that!