Snap – I’ve got the package!

Ba-ba-bam. Now, the number of puns and historic and cultural references that can be applied here is way, way too high. We have the mandatory Eurodance homage, but also the Google Chrome throw-a-hissy page and the Lonely Island Mother Lover song words. All good and well. But have you thought about Ubuntu, at all?

Snap is the name of the new application packaging format for the Ubuntu core system. It differs from the standard RPM and DEB and whatnot in that it contains all the dependencies required to run the program, so you do not really rely on the underlying system capabilities. In other words, this is the first attempt by Canonical to create portable Ubuntu applications. Welcome.

More detail

Snap packages (.snap) are application containers. Under the hood, it’s all YAML, and this means you actually create packages using recipes — or rather playbooks, very similar to Ansible and Chef and other configuration management tools. You develop using snapcraft, which helps you bundle your applications, and you declare your work using the snapcraft.yaml file. Then, you deploy on Snappy, a minimal server image of Ubuntu specifically designed to support this new framework.

No nerdy project would be complete without git, GOLANG and other merry concepts, but then, this is what people seem to like. Software development is more text-declarative nowadays, and revolves around silly data formats, like JSON. And yes, if you read the official page, it will say something like: “it is easy for humans to read and write“. Right. Never mind me. We will explore this in detail very soon.

Why is all this important?

Well, for several reasons. If you’ve followed the news, you may have heard that you can now install Ubuntu software on top of Windows 10. An easy way to achieve this is to use statically compiled software, or at least, bundle all the necessary dependencies into an archive, so that programs can run merrily with a minimum number of external drivers, and by drivers, I do not mean hardware drivers.

Then, mobile. Think Android, and then the link becomes clear. Snap packages are an early attempt by Canonical to help people develop Ubuntu software that can be tested fully independently, without relying on large, expensive systems. Or the assumption that specific components will be present on the target device. Or that nothing is going to break come the update of a shared library or another system component. The easy way to avoid all these is to create all-included self-sufficient software package.

Fast forward a year or two, if Canonical is successful, you will be able to run Ubuntu software anywhere you want, and it will truly be Ubuntu software, in the full sense of the meaning, including any third-party licenses you may need. They will be packaged and distributed without any ambiguity into how the software works or interacts with target platforms. Then, extrapolate into the mobile and the classic PC space, the attempt by Canonical to web the desktop and the phone, the Windows-Linux bridge, and the brand recognition that puts Ubuntu apart from the rest of the Linux bunch, just like Android did, That is most likely the vision, or large parts of it. Now, let’s see how this works.

Getting started

I must say I was a little overwhelmed by all the terminology. Not really, but I do have a big aversion for name-dropping. And as a person with a really decent tech savvy, I do struggle with the fact developing software has become modular to the point of confusion. But let’s say you can ignore this piece. You don’t mind the dozen different tools and frameworks, just to get your first program up and running.

I tested the snap functionality on Ubuntu 16.04. It comes with a package called snapd, which provides the basic functionality. In previous versions, it used to be snappy. Then, you do need to manually install snapcraft, if you feel like writing code.

Snap commands are a frontend to whatever functionality runs in the background, and allows you to download and install snap packages. At the moment, the official repository contains a very small selection of demo software. To check what’s available, run snap find:

snap find
Name                  Version                   Summary
audovia               3.2.2                     Database application for making music using JFugue MusicStrings
beagleblack           3.1                       OEM Beagle Bone Black
canonical-dragon      0.7.1                     The gadget snap for the dragonboard
canonical-i386        3.1.i386                  The gadget snap for generic i386 systems
canonical-pc          3.2                       AMD64 generic package
canonical-pc-linux    4.4.0-18+20160419.13-26   The ubuntu-core kernel snap
canonical-pi2         3.2                       Raspberry Pi 2 support package
go-example-webserver  16.04-4                   Minimal Golang webserver for snappy
...

Let’s install one or two applications, to see what gives. You still need sudo privileges to install software. I started with the Ubuntu clock core app, and it was a hefty 120MB download, which can easily be explained by the need to bundle all the needed dependencies.

Install package

Once the clock was installed, I started it. From the command line, you invoke the Snap packages in a slightly convoluted way. You call them by name, but you also need to reference their suffix, which often denotes their functionality. For instance, ubuntu-clock-app is actually ubuntu-clock-app.clock. Redundant much?

Clock app

The clock was running fine, and it was actually showing the right time. You can also use the stopwatch functionality, as well as add new locations. In essence, this is very similar – if not identical – to the mobile app we’ve seen on the Ubuntu Phone as well as the BQ Aquaris M10 tablet recently. On the desktop, the clock GUI wasn’t too sharp, the contrast was a little off, and some of the colors looked a little faded, but it’s a start.

Once you have one or several Snap packages installed, you can update them using the refresh command, delete them, or just grab the list of what’s on your system. It’s a package manager all right, except that it’s tied into the development framework, too. This makes sense in a way, if you expect people to use your system AND develop for it.

Installed packages

The functionality is not without flaws. During one of the installs, I hit Ctrl + C to break the process, but then it continued in the background. However, I was not aware that the installation was still active, and when I tried to run additional commands, I got a bunch of errors.

sudo snap install moon-buggy
error: can't install "moon-buggy": snap "ubuntu-core" has changes in progress

You cannot install programs twice, either:

sudo snap install moon-buggy
error: can't install "moon-buggy": snap "moon-buggy" already installed

Then, trying to run the Buggy game, it complained that it cannot open a score file, which I’d presume is music. I have no idea what it would encounter a permission denied error for the user’s home dir, but then this is still all early work, and bugs are expected. Moon Buggy is buggy. Tee hee.

moon-buggy.play 
Fatal error: Cannot open score file "/home/roger/.mbscore": Permission denied

Development

I didn’t go into this too deeply. Again, I try to avoid coding as much as I can, because I’m not fond of the concept of writing software for a living. But I still wanted to see how easy and accessible the Snap framework would be. After all, if Canonical wants millions developing software for its platform, it’d better provide a simple, easy, seamless setup, right?

I tried running snapcraft, and immediately ran [sic] into problems. It was complaining that it could not find the snapcraft YAML file. Not good. The karma is not strong in this one.

snapcraft 
Could not find snapcraft.yaml. Are you sure you are in the right directory?
To start a new project, use 'snapcraft init'

I created a new project, but then, it complained about properties, schemas and strings. Nope. This is not how it’s meant to be. I mean, if I created the snapcraft YAML project file using the software framework tools, then it’d better have the right syntax and throw no errors. C’mon, seriously. This also reminds me why I don’t like writing code.

snapcraft init
Created snapcraft.yaml.
snapcraft 
Issues while validating snapcraft.yaml: The 'name' property does not match the required schema: None is not of type 'string'

Conclusion

Overall, the concept of Snap packages sounds interesting, practical, useful, and beneficial, both to the Ubuntu ecosystem and the future proliferation of the Ubuntu operating system outside the desktop space. But then, the idea is no different than any one similar framework in the sea of fragmented, namedrop-rich software development. Essentially, it’s just another setup that aims to be ever so slightly unique, but all it is is confusing. And if there’s one thing to be said about modern development is that it comes with way too many little components. Modularity is all good and fine, but I don’t want to be RESTful, I don’t want to use any API, and I sure don’t feel like golanging anything. Especially not all at the same time.

If you cast your eyes about, then you will realize that lots of new software bear the same hallmark of non-intuitive complexity. The fact something is popular does not make it efficient or the right way of doing things. I’m not sure this is the right way forward. But ignoring my techno-spiel, the Snap framework needs a lot more work. It’s still very buggy, it’s not streamlined enough, and it does not provide any great advantage over Firefox OS or Android. The fact you will be able to run Ubuntu stuff on Windows is of great value, and it could be the spur in the ribs of the open-source horse. But I can’t say for sure, yet, it’s a little too early for that.

Anyhow, if you’re interested in expanding your hi-tech vocabulary, you might want to try dabbling in Snap. As far as I’m concerned, the dev piece is as arcane as any recent project, but the idea of independent software that can run anywhere is great. It might be what Ubuntu needs to go big. And having yet another framework in the world of Linux sure ain’t going to break the camel’s back. I’m going native here with all these animal references. Indeed, we’re done. Let’s see how this evolves. Snap!


Cover Photo: Drone Delivery by DodgertonSkillhause for the Morguefile.com.

[sharedaddy]

3 thoughts on “Snap – I’ve got the package!

  1. This sounds familiar. When I received my Ubuntu Phone over a year ago one of the first things I did was try and create a simple HTML5 app for it. I couldn’t get it to work, errors all over the place right from the off. So I downloaded a template HTML5 app from the Ubuntu developer website and followed the walk-through there – that didn’t work either. I haven’t bothered since; I hope the problems with snap don’t put people off as easily as I was.

Leave a Reply