Snap error on Amazon Linux 2023

Hello. I’d like to install Certbot on Amazon Linux EC2 instance. The documentation recommends using Snap. I am getting errors when trying to install any snap.

Here are the articles I’ve already gone through:

Along with the following (I was only allowed to put 2 links in this post, so I had to preformat them)

https://github.com/albuild/snap (Followed Install for Amazon WorkSpaces instructions)

https://forum.snapcraft.io/t/cannot-install-snapd-on-amazon-linux-2/20824

https://forum.snapcraft.io/t/cannot-install-snap-file-snap-is-unusable-due-to-missing-files/25719 (I am unable to downgrade squashfs-tools)

https://forum.snapcraft.io/t/unofficial-snapd-repository-for-amazon-linux-2/24269 (The unofficial repository is no longer accessible)

$ cat /etc/os-release
NAME="Amazon Linux"
VERSION="2023"
ID="amzn"
ID_LIKE="fedora"
VERSION_ID="2023"
PLATFORM_ID="platform:al2023"
PRETTY_NAME="Amazon Linux 2023"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2023"
HOME_URL="https://aws.amazon.com/linux/"
BUG_REPORT_URL="https://github.com/amazonlinux/amazon-linux-2023"
SUPPORT_END="2028-03-15"

$ cat /etc/amazon-linux-release
Amazon Linux release 2023 (Amazon Linux)

$ cat /proc/version
Linux version 6.1.72-96.166.amzn2023.x86_64 (mockbuild@ip-10-0-50-38) (gcc (GCC) 11.4.1 20230605 (Red Hat 11.4.1-2), GNU ld version 2.39-6.amzn2023.0.10) #1 SMP PREEMPT_DYNAMIC Wed Jan 17 00:42:52 UTC 2024

All of the following commands ran without issue

$ sudo mkdir /opt/albuild

$ sudo mkdir /opt/albuild/snap

$ cd /opt/albuild/snap/

$ sudo wget https://github.com/albuild/snap/releases/download/v0.1.0/snap-confine-2.36.3-0.amzn2.x86_64.rpm

$ sudo wget https://github.com/albuild/snap/releases/download/v0.1.0/snapd-2.36.3-0.amzn2.x86_64.rpm

$ sudo yum -y install /opt/albuild/snap/snap-confine-2.36.3-0.amzn2.x86_64.rpm /opt/albuild/snap/snapd-2.36.3-0.amzn2.x86_64.rpm

$ sudo systemctl enable --now snapd.socket

$ sudo ln -s /var/lib/snapd/snap /snap

$ sudo reboot

$ snap --version
snap    2.36.3-0.amzn2
snapd   2.36.3-0.amzn2
series  16
amzn    2023
kernel  6.1.72-96.166.amzn2023.x86_64


But I receive the following error when I try to install anything with snap

$ sudo snap install --classic hello-world
error: cannot perform the following tasks:
- Mount snap "core" (16202) (snap is unusable due to missing files; contact developer)

$ sudo snap install --classic certbot
error: cannot perform the following tasks:
- Mount snap "core20" (2105) (snap is unusable due to missing files; contact developer)

This is the result when I tried to downgrade squashfs

$ sudo yum downgrade squashfs-tools
Last metadata expiration check: 4:33:27 ago on Fri Jan 26 13:47:07 2024.
Package squashfs-tools of lowest version already installed, cannot downgrade it.
Dependencies resolved.
Nothing to do.
Complete!

Any help would be appreciated.

Thank you!

Hi ! @it-tt

To install a program with classic confinement, it would have to be classic confinement. A strict confinement program cannot be installed with the --classic option.

Well , if the confinement does not the source of problems.

First of all, I recommand you to try this scenario :

sudo yum install squashfs-tools

sudo modprobe squashfs

This is a very old version and I have no idea what GitHub - albuild/snap: Snappy for Amazon Linux 2 repository is nor who maintains it.

The location of relevant specs which were used to build and publish the repository is linked to here: Unofficial snapd repository for Amazon Linux 2 - #31 by mborzecki1 If you are in an immediate need of installing snapd on Amazon Linux 2023, I suggest you rebuild the packages yourself.

@baldeuniversel Ah, I should’ve mentioned I had tried to install certbot without the --classic option first. According to the error message and their documentation, it required the --classic flag.

$ sudo snap install certbot
error: This revision of snap "certbot" was published using classic confinement and thus may perform arbitrary system changes outside of the security sandbox that snaps are usually confined to, which may put your system at risk.

If you understand and want to proceed repeat the command including --classic.

@mborzecki1 Thank you. I actually saw that article, and if you look in my original post, I have it listed as one of the ones I read. However, the repository you link to in that article shows as “403 Forbidden”, and in the thread you mentioned that you don’t work at Canonical anymore and it was no longer maintained by you.

Hope was further lost when compuguy replied with a ticket number for someone requesting support in Amazon Linux 2022 but Amazon replied with they wouldn’t be adding it to Amazon Linux 2023 either.

However, now I see you linked to https://github.com/bboozzoo/snapd-amazon-linux I will give this repository a try. Thank you.

@baldeuniversel

No dice on re-installsing squashfs-tools - just a message stating it was already installed. What does modprobe do? I didn’t see any output.

$ sudo yum install squashfs-tools
Last metadata expiration check: 20:48:49 ago on Sun Jan 28 17:50:26 2024.
Package squashfs-tools-4.5-3.amzn2023.0.2.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
$ sudo modprobe squashfs
$ sudo snap install certbot --classic
error: cannot perform the following tasks:
- Mount snap "core20" (2105) (snap is unusable due to missing files; contact developer)

I’ll try out the other repository that @mborzecki1 mentioned and keep ya’ll posted.

I’ve landed an update to 2.61.1 and I’m looking if maybe there’d be a way to publish a built repo through github pages.

For now you can clone directly from github, fetch the source tarballs (rpmspec -P snapd.spec | grep -E 'Source[0-9]+:') and build them yourself using rpmbuild or run ./tool build in the checkout directory (assuming Docker/Podman is set up locally).

Yep ! @it-tt

It could solve the issue .

@mborzecki1 Here are the commands I ran in an attempt to build and install the package but did not have success. I don’t have Docker/Podman setup.

The install seems to work using rpm but fails when using yum localinstall. Either way, the app does not show as installed afterwards. Any output from commands that weren’t successful or had notable messaging have been included.

Any assistance is appreciated. Thanks so much!

$ sudo yum remove snapd

$ sudo git clone https://github.com/bboozzoo/snapd-amazon-linux /opt/bboozzoo/snapd-amazon-linux/

$ sudo yum install rpm-build

$ whereis rpm
rpm: /usr/bin/rpm /usr/lib/rpm /etc/rpm /usr/share/man/man8/rpm.8.gz

$ sudo rpmspec -P /opt/bboozzoo/snapd-amazon-linux/snapd.spec | grep -E 'Source[0-9]+:'

Source0:        https://github.com/snapcore/snapd/releases/download/2.61.1/snapd_2.61.1.no-vendor.tar.xz

Source1:        https://github.com/snapcore/snapd/releases/download/2.61.1/snapd_2.61.1.only-vendor.tar.xz

$ rpmdev-setuptree

$ wget https://github.com/snapcore/snapd/releases/download/2.61.1/snapd_2.61.1.no-vendor.tar.xz -P /home/ec2-user/rpmbuild/SOURCES/

$ wget https://github.com/snapcore/snapd/releases/download/2.61.1/snapd_2.61.1.only-vendor.tar.xz -P /home/ec2-user/rpmbuild/SOURCES/

$ cp /opt/bboozzoo/snapd-amazon-linux/snapd.spec /home/ec2-user/rpmbuild/SPECS/snapd.spec

$ rpmlint /home/ec2-user/rpmbuild/SPECS/snapd.spec
[…]
0 packages and 1 specfiles checked; 2 errors, 26 warnings.

$ rpmbuild -bs /home/ec2-user/rpmbuild/SPECS/snapd.spec
setting SOURCE_DATE_EPOCH=1706486400
Wrote: /home/ec2-user/rpmbuild/SRPMS/snapd-2.61.1-1.amzn2023.1.src.rpm

$ sudo rpm -ivh /home/ec2-user/rpmbuild/SRPMS/snapd-2.61.1-1.amzn2023.1.src.rpm
Updating / installing...
   1:snapd-2.61.1-1.amzn2023.1        ################################# [100%]

$ rpm -qi snapd
package snapd is not installed

$ sudo yum localinstall /home/ec2-user/rpmbuild/SRPMS/snapd-2.61.1-1.amzn2023.1.src.rpm
Last metadata expiration check: 1 day, 1:37:26 ago on Sun Jan 28 17:50:26 2024.
Error:
 Problem: conflicting requests
  - nothing provides /usr/bin/shellcheck needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(github.com/boltdb/bolt) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(github.com/coreos/go-systemd/activation) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(github.com/godbus/dbus) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(github.com/godbus/dbus/introspect) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(github.com/gorilla/mux) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(github.com/jessevdk/go-flags) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(github.com/juju/ratelimit) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(github.com/kr/pretty) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(github.com/kr/text) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(github.com/mvo5/goconfigparser) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(github.com/seccomp/libseccomp-golang) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(github.com/snapcore/go-gettext) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(golang.org/x/crypto/openpgp/armor) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(golang.org/x/crypto/openpgp/packet) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(golang.org/x/crypto/sha3) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(golang.org/x/crypto/ssh/terminal) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(golang.org/x/xerrors) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(golang.org/x/xerrors/internal) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(gopkg.in/check.v1) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(gopkg.in/macaroon.v1) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(gopkg.in/mgo.v2/bson) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(gopkg.in/retry.v1) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(gopkg.in/tomb.v2) needed by snapd-2.61.1-1.amzn2023.1.src
  - nothing provides golang(gopkg.in/yaml.v3) needed by snapd-2.61.1-1.amzn2023.1.src
(try to add '--skip-broken' to skip uninstallable packages)

You don’t need to build the src.rpms nor install them. Just go ahead and run rpmbuild -bb snapd.spec to build the binary packages, then install the resulting RPMs (as in the actual *.rpm, not *.src.rpm).

@mborzecki1 Thank you for this. After correcting that command, the build still failed due to a bunch of missing dependencies. I was able to install most of them using yum but ran into some trouble when using Go. Something tells me there is an easier way to pull these dependencies.

Here is the original unabridged list of required dependencies:

$ rpmbuild -bb /home/ec2-user/rpmbuild/SPECS/snapd.spec
setting SOURCE_DATE_EPOCH=1706486400
error: Failed build dependencies:
        /usr/bin/shellcheck is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        autoconf is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        autoconf-archive is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        automake is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        compiler(go-compiler) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        gcc is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        glibc-static is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(github.com/boltdb/bolt) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(github.com/coreos/go-systemd/activation) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(github.com/godbus/dbus) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(github.com/godbus/dbus/introspect) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(github.com/gorilla/mux) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(github.com/jessevdk/go-flags) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(github.com/juju/ratelimit) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(github.com/kr/pretty) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(github.com/kr/text) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(github.com/mvo5/goconfigparser) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(github.com/seccomp/libseccomp-golang) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(github.com/snapcore/go-gettext) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(golang.org/x/crypto/openpgp/armor) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(golang.org/x/crypto/openpgp/packet) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(golang.org/x/crypto/sha3) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(golang.org/x/crypto/ssh/terminal) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(golang.org/x/xerrors) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(golang.org/x/xerrors/internal) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(gopkg.in/check.v1) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(gopkg.in/macaroon.v1) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(gopkg.in/mgo.v2/bson) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(gopkg.in/retry.v1) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(gopkg.in/tomb.v2) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(gopkg.in/yaml.v2) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(gopkg.in/yaml.v3) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        libseccomp-static is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        libtool is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        make is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        pkgconfig(glib-2.0) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        pkgconfig(libcap) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        pkgconfig(libseccomp) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        pkgconfig(libselinux) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        pkgconfig(libudev) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        selinux-policy-devel is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        valgrind is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        xfsprogs-devel is needed by snapd-2.61.1-1.amzn2023.1.x86_64

Here are the ones I was able to install using yum:

$sudo yum install golang

$sudo yum install glibc-static

$sudo yum install autoconf

$sudo yum install autoconf-archive

$sudo yum install automake

$sudo yum install libseccomp-static

$sudo yum install libtool

$sudo yum install ‘pkgconfig(glib-2.0)’

$sudo yum install 'pkgconfig(libcap)'

$sudo yum install 'pkgconfig(libudev)'

$sudo yum install selinux-policy-devel

$sudo yum install xfsprogs-devel

$sudo yum install valgrind

$sudo yum install 'compiler(go-compiler)'

So then I was left with fewer (a sample has been selected):

$ rpmbuild -bb /opt/bboozzoo/snapd-amazon-linux/snapd.spec
setting SOURCE_DATE_EPOCH=1706486400
error: Failed build dependencies:
        /usr/bin/shellcheck is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        golang(github.com/boltdb/bolt) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        [...]
        golang(golang.org/x/crypto/sha3) is needed by snapd-2.61.1-1.amzn2023.1.x86_64
        [...]
        golang(gopkg.in/yaml.v3) is needed by snapd-2.61.1-1.amzn2023.1.x86_64

Here is the result of when I tried to install the others using Go:

$ sudo go install golang.org/x/crypto@latest
go: golang.org/x/crypto@latest: module golang.org/x/crypto@latest found (v0.18.0), but does not contain package golang.org/x/crypto

$ sudo go get github.com/boltdb/bolt
go: go.mod file not found in current directory or any parent directory.
        'go get' is no longer supported outside a module.
        To build and install a command, use 'go install' with a version,

$ sudo go install github.com/boltdb/bolt@latest
package github.com/boltdb/bolt is not a main package

So I try to create my own Go module so I can use get and build

$ cd /opt/bboozzoo/snapd-amazon-linux/
$ sudo go mod init example.com/snapd
$ sudo echo 'package snapd' | sudo tee -a /opt/bboozzoo/snapd-amazon-linux/snapd.go
$ sudo go get github.com/boltdb/bolt
$ sudo go build github.com/boltdb/bolt
$ sudo go install github.com/boltdb/bolt

But it still shows in the list of dependencies, so this is obviously not the way to get those incorporated into the RPM build. There must be an easier way. But if not, that’s fine - any idea how to pull the rest of the dependencies?

I’m working on updating the packaging so that it works on Amazon Linux 2023 as well. I hope to get something done today.

1 Like

The repositories are up. Please see instructions provided in

1 Like

@mborzecki1 Awesome! The new package worked perfectly on Amazon Linux 2023. 3 gold stars for you! Consider this resolved!

$ sudo wget -O /etc/yum.repos.d/snapd.repo https://bboozzoo.github.io/snapd-amazon-linux/al2023/snapd.repo
[...]
$ sudo dnf install snapd -y
[...]
$ sudo snap install --classic certbot
2024-02-01T05:22:55Z INFO Waiting for automatic snapd restart...
certbot 2.8.0 from Certbot Project (certbot-eff✓) installed