Skip to main content

ARM64 Snap!

· 3 min read
Anirudh Sevugan
Tech Enthusiast

SimpliPlay now has an arm64 version available on the Snap Store!

I followed the Beekeeper Studio guide (which was very nice and ad-free by the way) online that gave me one crucial command:

SNAPCRAFT_BUILD_ENVIRONMENT=host yarn run electron-builder build --linux snap --arm64 --armv7l

Since I don't use yarn in my setup (and would rather not try), I changed this to:

SNAPCRAFT_BUILD_ENVIRONMENT=host USE_SYSTEM_FPM=true npx electron-builder --linux snap --arm64

Now, normally this would work. I tried it on an Ubuntu 22.04 ARM GitHub Actions runner, and it seemingly worked. But when I tested on my VM, it said that a specific version of GLIBC was required, which wasn't installed on the system.

Snaps don't require any libraries to be installed. I tried to use apt to solve the problem but that failed, and the app just silently didn't launch.

When I launched it via the command line, I noticed the problem. I went back and took a look at the logs while building in CI/CD, and they said the exact same thing, but oddly enough compiled anyway.

I put my thinking hat on and realized that electron-builder uses the core20 base by default. In short, bases are for building Snaps with a base of libraries. But, the core20 base required an older version of GLIBC that wasn't included with the Ubuntu 22.04 ARM runner, since it needs core22, which would work on Ubuntu 22.04+, which is a substantial portion of my userbase, along with newer versions of non-Ubuntu OSs that supported Snaps.

I (stupidly) tried to use a Ubuntu 20.04 runner (which would work properly with core20 and package the GLIBC versions from the system due to the environment variables set to avoid using LXD and multipass to build in a VM, which ARM doesn't properly support even on a real device).

But that didn't exist. So I had to manually set build.snap.base in my package.json to core22, along with using the Ubuntu 22.04 runner instead of 20.04. But then the x64 builds already worked properly with whatever core it was using, so I didn't want to interfere with it.

So I made a new package.json just for ARM64 Linux, named package-arm64-linux.json, which is renamed to package.json while the existing one for non-ARM64 Linux was renamed to package-unused.json at runtime. Other jobs don't do this, so only arm64 Linux will perform this action.

I thought it would work after that, but then installing packages needed for building failed when they were installed during the build process. I was confused, but then realized that manually installing those packages before building may fix it, because building is often sandboxed. I was right after that, and the ARM64 Snap worked successfully on the VM, no issues needed.

It is just it took a few seconds to start, so I thought it failed again till I waited a bit longer :)