The Linux Rain Linux General/Gaming News, Reviews and Tutorials

Snaps vs Flatpak? Both!

By Andrew Powell, published 23/06/2016 in Editorial


We recently did a little article on Canonical's "Snappy" system, also known as Snaps, and it's usefulness for testing new and updated software without breaking your existing installations or versions of that specific software. Akin to Upstart vs systemd, Red Hat also have their own slice of "bundled app" pie in the form of Flatpak. So naturally the internet breaks out in arguments for each and you may wonder, which one should I install and try out? Thankfully due to the nature of the software, you can install both!

You may wonder why you would want to. Well, simply, because we can.

Just backtracking a little, Flatpak was recently announced, no doubt somewhat in response to all the press Canonical's Snaps were getting. Flatpak has actually been around and available for testing for some months, but a good press release is always good to spread word to the masses. I should also point out that Flatpak isn't entirely a Red Hat project per se, though it was developed by a Red Hat employee. It is however a part of the Freedesktop project and was once known as xdg-app, though obviously Flatpak was seen as a much nicer and public-friendly name.

However, it should be noted that Flatpak (and indeed, Snappy) is still in development and not ready for prime time as far as every day users go. But if you have a little terminal-foo and feel like playing around a bit, you can install either one or even both on your system right now. As I write this article on an Ubuntu 16.04 (GNOME) machine, I have both Snappy and Flatpak installed with no issues and have tested a few pieces of software from both, even at the same time. As I said, due to the nature of both softwares, there shouldn't be any conflicts or problems because the apps are safely contained in their own environment.

This article also doesn't attempt to really compare or list all the differences between Snappy and Flatpak as that's a topic being hotly debated in various forums and websites at the time of writing. A simple search of "Snappy vs Flatpak" in your search engine of choice will yield plenty of results and I would recommend keeping an open mind. I also won't claim to be an expert on the technical aspects of either one.

I am however an expert "fence-sitter"! So naturally I like trying out both and seeing how they perform even in these relatively early days. If you too wish to install Flatpak, keep reading.

Installing

The "Getting Flatpak" page of the Flatpak website currently has instructions for Arch, Debian, Fedora, Mageia and Ubuntu. I would recommend following those instructions for your specific distribution, assuming you are running one of those listed.

If you are running Fedora 23 or newer though, a simple sudo dnf install flatpak will get you want you want as Flatpak is already in the official repo.

Usage (and a little note about those Runtime thingies)

Once installed, no doubt you are aching to install a "Flatpak" app. It's here you will realise one difference to Snappy already.

While Snappy apps include pretty much all the needed components for an app to work in the actual app bundle itself, Flatpak apps are instead built against a specific "runtime". For example, right now you can install a Flatpak version of LibreOffice 5.2 beta2 which is targeted (and therefore requires) the latest GNOME Platform 3.20 Runtime. Many apps will likely be written against such a runtime, so if you install the GNOME 3.20 Runtime, for example, you will install it once and those apps which require it will automatically have their dependencies met (unless they're complex enough to also require other runtimes, which you would then install also).

In fact, while there are only a handful of Flatpak apps you can install at the time of this writing, most of them seem to require the GNOME 3.20 runtime so I would recommend installing that first. Which can be done as thus:

First, we need to add the GNOME repositories.

wget https://sdk.gnome.org/keys/gnome-sdk.gpg
flatpak remote-add --gpg-import=gnome-sdk.gpg gnome https://sdk.gnome.org/repo/
flatpak remote-add --gpg-import=gnome-sdk.gpg gnome-apps https://sdk.gnome.org/repo-apps/

Then, issue the install command. Note that the GNOME runtime will be at least 150MB or so in download size. But this does mean the apps that require it will be fairly small to download later.

flatpak install gnome org.gnome.Platform 3.20

As you can see the commands and the naming conventions seem a bit long-winded, but you start to get a feel for it eventually.

So, finally, let's install and run an app! As mentioned, there aren't many to choose from at this stage, but as with Snappy, this will likely change quickly as things gather steam. Since we added the GNOME apps repository before, we already have access to most of the usual GNOME apps which you can install right away. As they require the latest GNOME upstream release of 3.20, they will be the latest stable version. Thankfully we also installed the GNOME 3.20 runtime before, so we're ready to rock and/or roll.

Listing apps in a repo is easy enough:

flatpak remote-ls gnome-apps --app

Once you've picked one, install like so (I've chosen gedit as an example):

flatpak install gnome-apps org.gnome.gedit

gedit itself only seems to be a 1.8MB download, which makes sense because the GNOME 3.20 runtime takes care of pretty much all its dependencies.

Then run (finally!):

flatpak run org.gnome.gedit

After a couple seconds, you should have a typical gedit text editor window open, which if you browse to the About section of the app, will tell you it is version 3.20. As an example, the version of gedit installed on my Ubuntu 16.04 system from the regular repos is still 3.18. So you can see what I mean about testing new versions of software.

As mentioned earlier, there is also a Flatpak version of LibreOffice. Follow that link to the LibreOffice Flatpak page for their official instructions. I can say the Flatpak LibreOffice seems to work just fine, as does the Snap version, although interestingly the theming and open dialogs seem to behave properly in the Flatpak version of LibreOffice whereas they didn't so much in the Snap version.

As an aside, you can also install an app such as "GIMP GTK+3". This is a cool little experiment because you get to try out a bleeding edge build of GIMP that is also built with GTK+3 support. Again, it requires the GNOME 3.20 runtime so no worries there.

First we do need a repo, as we are now installing from a repo called nightly-graphics (Inkscape and MyPaint are also available here):

wget http://209.132.179.2/keys/nightly.gpg
flatpak remote-add --gpg-import=nightly.gpg nightly-graphics http://209.132.179.2/repo/

Then install and run:

flatpak install nightly-graphics org.gimp.GimpDevelGtk3
flatpak run org.gimp.GimpDevelGtk3

That's all there is to it.

For more information give the Flatpak official site a look as there's plenty of information there, including info on how to build your own .flatpak builds.

Summary

As you can see, the command-line interface to Flatpak is a little long-winded and takes some getting used to, but is functionally sound and at least has tab completion as well. The fact you have to actually add repositories probably seems annoying too, however, it does kind of make sense. Installing Flatpak freshly, on its own, you can understand it not coming pre-configured with repos. In future, any distro utilizing Flatpak properly will include the relevant repos out of the box, and any extra repos you would have to add like you do on any .deb or .rpm based system anyway. Plus, there is apparently work in progress to integrate Flatpak into the likes of GNOME Software, so the graphical side of things will be handled for those of you wishing to steer clear of the terminal.

So, if like me, you now have Flatpak and Snappy installed on your Linux system it will be interesting to see how things progress from here. More and more apps should come along that support both and really, I see it as a good thing to have more choice. It probably seems redundant to have both Flatpak and Snappy installed at the same time when ultimately they seem to do the same thing on a simplistic level, in terms of allowing you to install sandboxed apps that should "just work", regardless of your host system and it's libraries. But it's in the name of fun and testing. The basic rule of thumb should be that if you can run Snappy or Flatpak, any of the software you install with those programs should work fine.

As for the future, it's hard to speculate entirely, but I imagine it will be the typical situation of Flatpak being used more broadly across the "community" while Snappy will be mostly Canonical's baby, albeit with lots of support behind it in the form of app support and of course Canonical's clout as a company as well. There is also the fact that as far as I know, Canonical will be utilizing Snappy technology even for the Ubuntu core operating system itself, especially for the server, whereas Flatpak is specifically designed for the desktop.

To this end I can't see why they can't co-exist. Again, I'm no expert, but it seems both Snaps and Flatpak are easy to build apps for, so hopefully it results in things being ultimately easier for app developers rather than harder and more fragmented. What ever happens, the debates will rage on and not everyone will be happy of course.

Oh the joy!



About the author

Andrew Powell is the editor and owner of The Linux Rain who loves all things Linux, gaming and everything in between.

Tags: red-hat flatpak canonical snappy snaps ubuntu fedora package-management ubuntu-16-04
blog comments powered by Disqus