I'm reading up on package distribution beyond PPAs, and find that Snap/Flatpak/etc. are the new craze.

I mostly have library-only software to package, e.g., LAPACK or some Python packages. As far as I understand, Snap is centered around executables and daemons.

Can Snaps install shared/dynamic libraries into /usr/lib at all? Where do I find documentation on this?


You can publish libraries as a shared part, or you can push a snap that offers the library as a content interface.

shared part

Snaps are composed of parts. If a snap depends on a library, it can be defined as a part. And parts can be shared, for now in a wiki, but with plans to build a fancier parts registry.

So, instead of publishing libraries as snaps in the Ubuntu Store, they should be published in the shared parts wiki. Then when a snap wants to use that library, let's say lapack, it just needs the following in a part in the snapcraft.yaml file:

after: [lapack]

The library will be bundled in the snap, and after installing the snap it will live somewhere around /snap/my-snap/current/usr/lib.

content interface

There's also another way to make your libraries available to other snaps. You can write your library as a snap that offers the content interface. Then other snaps can consume that content, which means that they will be able to access the libraries shared by the provider. With the caveat that the interface will be auto-connected only for snaps from the same publisher, if you want to consume something provided by a third-party it will need manual intervention.

This is how the ubuntu-app-platform libraries are shared with the default Ubuntu Personal apps: https://insights.ubuntu.com/2017/01/26/using-the-ubuntu-app-platform-content-interface-in-app-snaps-2/

To answer your final question, snaps can't install files in /usr/lib.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.