Snapcraft Extensions

Snapcraft extensions enable snap developers to easily incorporate a set of common requirements into a snap.

These requirements can include build and staging packages, plugs and interfaces, file layouts and environments, and whatever other snapcraft.yaml elements may be required to build a functioning system.

For a full list of supported extensions, see Supported extensions.

A snap developer creating a GTK 3 application snap, for example, can use the gnome-3-28 extension to expose the GTK 3 libraries to a snap at build and runtime without the snap developer needing specific deep knowledge about GTK 3. There are extensions for building robotics (ROS 2) applications too, including the ROS2 Humble Extension.

Extensions help:

  • avoid repetitive tasks in the snap building process
  • obviate the need for in-depth knowledge of the target software stack
  • create a standard template for common application requirements
  • reduce the testing and security burden, as they’re tested and updated independently

ⓘ For more details on the snap building process, see Creating a snap.

Using Extensions

To use an extension, at least one app section of the snap’s snapcraft.yaml needs to reference the extension.

The following snippet, for example, shows how the Firefox snap uses the gnome-3-34 extension to add Gnome desktop support:

    command: firefox
    command-chain: [tmpdir]
    desktop: distribution/firefox.desktop
    extensions: [gnome-3-34]

All extensions are included with Snapcraft and can be listed with the following command:

$ snapcraft extensions
Extension name    Supported bases
----------------  -----------------
gnome-3-28        core18
gnome-3-38        core20
kde-neon          core18, core20

See Supported Extensions for the full list of extensions.

Further information about any specific extension can be obtained by typing snapcraft extension followed by the extension name:

$ snapcraft extension gnome-3-28
This extension eases creation of snaps that integrate with GNOME 3.28

Extensions modify the snapcraft.yaml definition before a build. You can use the expand-extensions command from your project’s root directory to see how the snapcraft.yaml file will look with the extensions applied.

$ snapcraft expand-extensions
name: foliate
    bind: $SNAP/gnome-platform/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/webkit2gtk-4.0
    bind: $SNAP/gnome-platform/usr/share/xml/iso-codes
    command: usr/bin/com.github.johnfactotum.Foliate
    - gsettings
    - home
    - desktop
    - desktop-legacy
    - wayland
    - x11
    - dbus-daemon
    common-id: com.github.johnfactotum.Foliate.desktop
    desktop: usr/share/applications/com.github.johnfactotum.Foliate.desktop
    - snap/command-chain/desktop-launch

@galgalesh thanks so much for this - this is great work which I’ll add to the top-level outline. We’ve currently got someone porting a number of the original Gnome packages to use the new Gnome extension, and they’re also (hopefully) making their own set of notes about the process which we’ll be able to incorporate here.


@galgalesh Might want to update this page for what I hope is an edge case…
On Ubuntu Desktop 18.04, when I installed snapcraft with:
sudo apt install snapcraft

If I run “snapcraft extensions”, I get no extensions supported.

I later tried installing it as a snap… but got the same result.
sudo snap install snapcraft --classic

And there is nothing in this page that details how to install gnome extension if it’s not there.

I noticed it when I was following Java applications and ran Snapcraft in the git clone directory.

Hello! Welcome to the forum, and thanks for letting us know about this.

I think the 18.04 deb package for snapcraft is still 2.43.1+18.04, and doesn’t include extensions. But the snap version you installed should (at the time of writing) be snapcraft 3.8, which does.

Maybe there’s confusion in your path (did you apt remove the original snapcraft installation?). Try which snapcraft, it should output the following:

$ which snapcraft
$ snapcraft version
snapcraft, version 3.8
$ snapcraft extensions
Extension name    Supported bases
----------------  -----------------
gnome-3-28        core18

By comparison, the older apt installed executable will be located as follows, and should be removed before installing the snap.

$ which snapcraft
$ snapcraft version
snapcraft, version 2.43.1+18.4
$ snapcraft extensions
No extensions supported

Hope that helps.

Thank you for your help! Yes, very confusing. I had first tried the snap and was told I had to use “–classic” flag, which made it sound like the old version, so I went with apt install instead…

So now that I uninstalled both apt and snap, and reinstalled the snap, it was able to build freeplane-1… but I got an error "an error occurred when using ‘multipass’ to query the status of the instance: returned exit code 2: info failed: failed to obtain exit status for remote process “free -b | sed ‘id;3d’ | awk ‘(printf $3)’’: timeout”.

This all seems kind of beta experience so far… not a single tutorial involving snaps/ubuntu mir-kiosk has worked out of the box. I guess a lot is still in flux on these two projects?

Thanks for the feedback! I added a note about using the latest Snapcraft version and I included the required Snapcraft version in the table of extensions.

Ideally, the Snapcraft version from apt should warn you that you’re using an outdated version. @degville is something like this in the works?

Yes, I believe it is, but I’ll make sure with the snapcraft team (Christmas holidays may get in the way of a quick response).


Two things I’d be interested in seeing here are:

  1. How can I create a new extension?
  2. Link to the repos where the currently available extensions are, so we don’t need to reinvent the wheel

I found this information to be very helpful. It does seem to be missing one thing. It would be nice if the “Using Extensions” section included a snippet from the snapcraft.yaml file before expansion showing how to use it in snapcraft.yaml.

Thanks for the feedback and the suggestion. I’ve added a snippet to show how extensions are defined within an example snapcraft.yaml, and it would be good to expand this document to include more general information, including the packages and connections they create which we currently gloss over. I’ll try and do this as soon as I can.

Minor nitpick, but it might be worth mentioning that you can run “snapcraft list-extensions” to list the extensions, where if you run “snapcraft help list-extensions”, it does admit that it is just an alias for the shorter “snapcraft extensions”.

I mention it only because “snapcraft --help” oddly displays “list-extensions” as a valid subcommand, but not “extensions.”

This link appears to be broken and I can’t find a replacement.

Thanks for looking into it. I’ve fixed the link (to Supported extensions).

The topic number is usually canonical, so you can often find things like this be removing the post title (which may have changed):

1 Like

I might mention the ROS2-related “ros2-humble” extension on this page as well. I realize it’s discussed in the Robotics section, but the earlier Plugins section mentions the core22 colcon plugin fort ROS2 so maybe for consistency, also mention ros2-humble here, if only to explain that it’s for ROS2 and it’s covered more completely in the Robotics section.

Good suggestion, thank you!

“To use an extension, the app metadata section of the snap’s snapcraft.yaml needs [to] include the extensions definition.”

Technically, would you not say, “To use an extension, at least one app definition in the ‘apps:’ section needs to reference the extension”?

I’ve tweaked this according to your suggestion, thank you!

Hello, I think we need to expand this article on how to develop a new Snapcraft extension.


This command appears to be outdated, running it tells me

Error: no such command 'extensions', maybe you meant 'list-extensions', 'expand-extensions' or 'revisions'

Running snapcraft list-extensions gives the output given in the article.

Was it brought back from dorm status?