I recently had a use-case to add
package-repositories to a snap I maintain (specifically, to add the LLVM apt repo so I could use a recent
clang as a build-package). However, this fails when I just run
snapcraft (i.e. when multipass is used):
$ snapcraft --enable-experimental-package-repositories *EXPERIMENTAL* package-repositories in use Launching a VM. *EXPERIMENTAL* package-repositories in use Hit:2 http://archive.ubuntu.com/ubuntu xenial InRelease Get:3 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB] Get:4 http://security.ubuntu.com/ubuntu xenial-security InRelease [109 kB] Reading package lists... Done E: The method driver /usr/lib/apt/methods/https could not be found. N: Is the package apt-transport-https installed? Failed to update the package cache: Some files could not be downloaded: failed to run apt update Check that the sources on your host are configured correctly.
And it fails in a different way when run with
$ snapcraft --use-lxd --enable-experimental-package-repositories *EXPERIMENTAL* package-repositories in use Launching a container. Waiting for container to be ready Waiting for network to be ready... *EXPERIMENTAL* package-repositories in use Hit:2 http://archive.ubuntu.com/ubuntu xenial InRelease Get:3 http://archive.ubuntu.com/ubuntu xenial-updates InRelease [109 kB] Get:4 http://security.ubuntu.com/ubuntu xenial-security InRelease [109 kB] Get:5 http://archive.ubuntu.com/ubuntu xenial-updates/main Sources [349 kB] Hit:1 https://apt.llvm.org/xenial llvm-toolchain-xenial InRelease Get:6 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 Packages [1179 kB] Get:7 http://archive.ubuntu.com/ubuntu xenial-updates/main Translation-en [442 kB] Get:8 http://archive.ubuntu.com/ubuntu xenial-updates/universe amd64 Packages [801 kB] Get:9 http://archive.ubuntu.com/ubuntu xenial-updates/universe Translation-en [335 kB] Get:10 http://security.ubuntu.com/ubuntu xenial-security/main Sources [167 kB] Get:11 http://security.ubuntu.com/ubuntu xenial-security/main amd64 Packages [903 kB] Get:12 http://security.ubuntu.com/ubuntu xenial-security/main Translation-en [336 kB] Get:13 http://security.ubuntu.com/ubuntu xenial-security/universe amd64 Packages [496 kB] Get:14 http://security.ubuntu.com/ubuntu xenial-security/universe Translation-en [204 kB] Fetched 5428 kB in 1s (2953 kB/s) Reading package lists... Done Could not find a required package in 'build-packages': clang-9
This is despite the fact that the
clang-9 package does exist: things proceed just fine with a
The particular lines added to
package-repositories: - type: apt deb-types: [deb] url: http://apt.llvm.org/$SNAPCRAFT_APT_RELEASE suites: [llvm-toolchain-$SNAPCRAFT_APT_RELEASE] components: [main] key-id: 6084F3CF814B57C1CF12EFD515CF4D18AF4F7421
… so note that this is not an
https URL! Rather, it seems that the URL is automatically switched to
https:// when snapcraft is run via multipass or LXD, but only inside LXD is apt https support auto-installed. Something else must be going wrong in the latter case, because there is no reason why
clang-9 should not be found (perhaps there is a silent failure to read from the apt repo instead?).
I appreciate the feature is still experimental, so no worries if this is just the way things are right now. But I’m sharing this just in case the issues haven’t been observed before, and also because it would be fun to find out what’s going on here. Can anyone shed any light?
Thanks and best wishes,