Installing Snapcraft on Manjaro

We tried all sorts of ways to install lxd and multipass under Manjaro with snap.

Snapcraft couldn’t access the LXD socket when I installed LXD using yay -S lxd (An official Arch package).

After removing the Arch built LXD we tried installing it using snap (snap install lxd), we’ve ran into an AppArmor error:

error: cannot perform the following tasks:
- Start snap "lxd" (23889) services (systemctl command [start snap.lxd.activate.service] failed with exit status 1: Job for snap.lxd.activate.service failed because the control process exited with error code.
See "systemctl status snap.lxd.activate.service" and "journalctl -xeu snap.lxd.activate.service" for details.

So we skipped that and installed multipass, ran snap set snapcraft provider=multipass and ran snapcraft into the following error:

Starting Snapcraft 7.2.6                                                                                                                                                                                           
Logging execution to '/home/yaron/.cache/snapcraft/log/snapcraft-20221107-182354.808208.log'                                                                                                                       
Running on amd64 for amd64                                                                                                                                                                                         
Launching instance...                                                                                                                                                                                              Traceback (most recent call last):
  File "/var/lib/snapd/snap/snapcraft/8513/lib/python3.8/site-packages/craft_providers/multipass/multipass.py", line 193, in list
    proc = self._run(command, text=True)
  File "/var/lib/snapd/snap/snapcraft/8513/lib/python3.8/site-packages/craft_providers/multipass/multipass.py", line 66, in _run
    return subprocess.run(command, check=True, capture_output=True, **kwargs)
  File "/var/lib/snapd/snap/snapcraft/8513/usr/lib/python3.8/subprocess.py", line 516, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['multipass', 'list', '--format', 'json']' returned non-zero exit status 2.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/snap/snapcraft/8513/bin/snapcraft", line 8, in <module>
    sys.exit(run())
  File "/var/lib/snapd/snap/snapcraft/8513/lib/python3.8/site-packages/snapcraft/cli.py", line 228, in run
    _run_dispatcher(dispatcher)
  File "/var/lib/snapd/snap/snapcraft/8513/lib/python3.8/site-packages/snapcraft/cli.py", line 204, in _run_dispatcher
    dispatcher.run()
  File "/var/lib/snapd/snap/snapcraft/8513/lib/python3.8/site-packages/craft_cli/dispatcher.py", line 448, in run
    return self._loaded_command.run(self._parsed_command_args)
  File "/var/lib/snapd/snap/snapcraft/8513/lib/python3.8/site-packages/snapcraft/commands/lifecycle.py", line 259, in run
    super().run(parsed_args)
  File "/var/lib/snapd/snap/snapcraft/8513/lib/python3.8/site-packages/snapcraft/commands/lifecycle.py", line 132, in run
    parts_lifecycle.run(self.name, parsed_args)
  File "/var/lib/snapd/snap/snapcraft/8513/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 208, in run
    _run_command(
  File "/var/lib/snapd/snap/snapcraft/8513/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 249, in _run_command
    _run_in_provider(project, command_name, parsed_args)
  File "/var/lib/snapd/snap/snapcraft/8513/lib/python3.8/site-packages/snapcraft/parts/lifecycle.py", line 531, in _run_in_provider
    with provider.launched_environment(
  File "/var/lib/snapd/snap/snapcraft/8513/usr/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/var/lib/snapd/snap/snapcraft/8513/lib/python3.8/site-packages/craft_providers/multipass/multipass_provider.py", line 105, in launched_environment
    instance = launch(
  File "/var/lib/snapd/snap/snapcraft/8513/lib/python3.8/site-packages/craft_providers/multipass/_launch.py", line 59, in launch
    if instance.exists():
  File "/var/lib/snapd/snap/snapcraft/8513/lib/python3.8/site-packages/craft_providers/multipass/multipass_instance.py", line 214, in exists
    vm_list = self._multipass.list()
  File "/var/lib/snapd/snap/snapcraft/8513/lib/python3.8/site-packages/craft_providers/multipass/multipass.py", line 195, in list
    raise MultipassError(
craft_providers.multipass.errors.MultipassError: Failed to query list of VMs.
* Command that failed: 'multipass list --format json'
* Command exit code: 2
* Command standard error output: "list failed: cannot connect to the multipass socket\nPlease ensure multipassd is running and '/var/snap/multipass/common/multipass_socket' is accessible\n"

Thanks @lucyllewy for her kind assistance!

Thank you for your assistance!

Does multipass work when not invoked by snapcraft? Can you run multipass launch and multipass list --format json at the shell?

For LXD, I was tired then to think of it, but just had the epiphany suggest this. LXD does ownership checks to see who is connecting to the socket. It is either root or someone in the lxd group. Can you try creating a lxd group, adding your user to it and then before running a lxd related command (if you don’t want to restart), run newgrp lxd

Just read the Arch wiki, and it indeed seems to be a required step https://wiki.archlinux.org/title/LXD#Accessing_LXD_as_an_unprivileged_user

@stgraber do you have ideas about the AppArmor error mentioned in this post:

Hmm, usually that’s a sign that the lxd-support interface didn’t get connected for some reason.

Well, it works and I can see the icon on the tray but that’s about it.

We ran through this as well, there is a group and I’m part of it.

Thanks, I’m wondering if there’s more verbosity to add to this process to have a better understanding of what’s going on in there.

Should I change something to make it work? How can I test it?

Error on Manjaro here to. It’s a fresh install (never works before)

  • On ubuntu 23.04 host SNAP v 5.14 works fine.
  • On Manjaro AUR the pkg version 5.14 (no SNAP) works too (less the LXD UI).
  • On Manjaro SNAP 5.14 got the error (behavior) bellow:
~  snap version                                                                                                                                                                                       
snap     2.59.5-1
snapd    2.59.5-1
series   16
manjaro  -
kernel   6.3.4-2-MANJARO

~  snap change 9                                                                                                                                                                                      
Status  Spawn               Ready               Summary
Done    today at 23:52 -03  today at 23:52 -03  Ensure prerequisites for "lxd" are available
Done    today at 23:52 -03  today at 23:52 -03  Download snap "lxd" (24918) from channel "candidate"
Done    today at 23:52 -03  today at 23:52 -03  Fetch and check assertions for snap "lxd" (24918)
Done    today at 23:52 -03  today at 23:52 -03  Mount snap "lxd" (24918)
Done    today at 23:52 -03  today at 23:52 -03  Copy snap "lxd" data
Done    today at 23:52 -03  today at 23:52 -03  Setup snap "lxd" (24918) security profiles
Done    today at 23:52 -03  today at 23:52 -03  Make snap "lxd" (24918) available to the system
Done    today at 23:52 -03  today at 23:52 -03  Automatically connect eligible plugs and slots of snap "lxd"
Done    today at 23:52 -03  today at 23:52 -03  Set automatic aliases for snap "lxd"
Done    today at 23:52 -03  today at 23:52 -03  Setup snap "lxd" aliases
Done    today at 23:52 -03  today at 23:52 -03  Run install hook of "lxd" snap if present
Doing   today at 23:52 -03  -                   Start snap "lxd" (24918) services
Do      today at 23:52 -03  -                   Run configure hook of "lxd" snap if present
Do      today at 23:52 -03  -                   Run health check of "lxd" snap
Done    today at 23:52 -03  today at 23:52 -03  Connect lxd:lxd-support to core:lxd-support
Done    today at 23:52 -03  today at 23:52 -03  Connect lxd:network to core:network
Done    today at 23:52 -03  today at 23:52 -03  Connect lxd:network-bind to core:network-bind
Done    today at 23:52 -03  today at 23:52 -03  Connect lxd:system-observe to core:system-observe
Done    today at 23:52 -03  today at 23:52 -03  Setup snap "lxd" (24918) security profiles for auto-connections

~ systemctl status snap.lxd.activate.service :heavy_check_mark: ● snap.lxd.activate.service - Service for snap application lxd.activate Loaded: loaded (/etc/systemd/system/snap.lxd.activate.service; enabled; preset: disabled) Active: activating (start) since Tue 2023-05-30 18:58:26 -03; 4h 48min ago Main PID: 3511 (daemon.activate) Tasks: 2 (limit: 18891) Memory: 768.0K CPU: 4h 46min 16.623s CGroup: /system.slice/snap.lxd.activate.service ├─ 3511 /bin/sh /snap/lxd/24918/commands/daemon.activate └─2394625 “[aa-exec]”

mai 30 18:58:26 george-minis systemd[1]: Starting Service for snap application lxd.activate… ~ 3 ✘ ~ sudo ls /var/snap/lxd/common/lxd/ 3 ✘ unix.socket ~ :heavy_check_mark: 3s  ~ sudo aa-status | grep lxd :heavy_check_mark: snap-update-ns.lxd snap.lxd.activate snap.lxd.benchmark snap.lxd.buginfo snap.lxd.check-kernel snap.lxd.daemon snap.lxd.hook.configure snap.lxd.hook.install snap.lxd.hook.remove snap.lxd.lxc snap.lxd.lxc-to-lxd snap.lxd.lxd snap.lxd.migrate snap.lxd.user-daemon ~ journalctl -xeu snap.lxd.activate.service

mai 30 18:58:26 george-minis systemd[1]: Starting Service for snap application lxd.activate…