OSError: can’t find 'ffms2' library, but the library is there

I am trying to generate the snap for subtitld, and I am getting this error saying libffms2 is not available. But the library is inside the snap.

Traceback (most recent call last):
  File "/snap/subtitld/266/bin/subtitld", line 8, in <module>
    sys.exit(main())
  File "/snap/subtitld/266/lib/python3.8/site-packages/subtitld/__main__.py", line 303, in main
    app.main = Subtitld()
  File "/snap/subtitld/266/lib/python3.8/site-packages/subtitld/__main__.py", line 102, in __init__
    from subtitld.modules import file_io
  File "/snap/subtitld/266/lib/python3.8/site-packages/subtitld/modules/file_io.py", line 22, in <module>
    from subtitld.modules import waveform
  File "/snap/subtitld/266/lib/python3.8/site-packages/subtitld/modules/waveform.py", line 11, in <module>
    import ffms2
  File "/snap/subtitld/266/lib/python3.8/site-packages/ffms2/__init__.py", line 33, in <module>
    from .libffms2 import *
  File "/snap/subtitld/266/lib/python3.8/site-packages/ffms2/libffms2.py", line 9, in <module>
    lib = get_library(
  File "/snap/subtitld/266/lib/python3.8/site-packages/ffms2/get_library.py", line 44, in get_library
    raise OSError("can’t find {!r} library".format(lib_name))
OSError: can’t find 'ffms2' library

Even if I install it on my system (of course, just as a test; asking users to install libraries to be able to use snap-based apps is out of question), the snap is not able to find the file (but strangely it knows what is the version/filename of the library in my system).

Traceback (most recent call last):
  File "/snap/subtitld/266/bin/subtitld", line 8, in <module>
    sys.exit(main())
  File "/snap/subtitld/266/lib/python3.8/site-packages/subtitld/__main__.py", line 303, in main
    app.main = Subtitld()
  File "/snap/subtitld/266/lib/python3.8/site-packages/subtitld/__main__.py", line 102, in __init__
    from subtitld.modules import file_io
  File "/snap/subtitld/266/lib/python3.8/site-packages/subtitld/modules/file_io.py", line 22, in <module>
    from subtitld.modules import waveform
  File "/snap/subtitld/266/lib/python3.8/site-packages/subtitld/modules/waveform.py", line 11, in <module>
    import ffms2
  File "/snap/subtitld/266/lib/python3.8/site-packages/ffms2/__init__.py", line 33, in <module>
    from .libffms2 import *
  File "/snap/subtitld/266/lib/python3.8/site-packages/ffms2/libffms2.py", line 9, in <module>
    lib = get_library(
  File "/snap/subtitld/266/lib/python3.8/site-packages/ffms2/get_library.py", line 45, in get_library
    return load_library(
  File "/snap/subtitld/266/lib/python3.8/site-packages/ffms2/get_library.py", line 167, in load_library
    return ctypes.CDLL(
  File "/usr/lib/python3.8/ctypes/__init__.py", line 373, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: libffms2.so.5: cannot open shared object file: No such file or directory

What am I missing? Here is the snapcraft.yml file.

I remember something similar happening before.

Likely you’ll need to patch your snap the same way as in the linked thread.

Yes, thanks, that worked! It’s sad to see the need of patches in order to make it work as it should. It’s a workaround, not a solution. But thank you for pointing to this thread, it helped me a lot. :wink: :+1:

I hope this issue get fixed someday.

I recall there was a thread a while ago discussing the possibility of per-snap ld caches, but it comes with a fair amount of complications of its own. In theory it could solve the problem though.

Realistically, I think the ideal technical fix here is at the Python implementation level, it’s just wrong to make an assumption that the cache is comprehensive, because it’ll disregard RPATH, RUNPATH, and $LD_LIBRARY_PATH, even when not running as a Snap.

Long story shortened, install binutils in your snap via a stage-packages entry.

1 Like

Unfortunately, installing binutils does not help. Just the patch.