Error: `'sudo' cannot be used with build provider 'multipass'`

I’m trying to build a new version of my program, but when I run sudo snapcraft it gives me this error:
'sudo' cannot be used with build provider 'multipass'.

I already build this package before (the last version), and I didn’t receive that error.

I tried to remove and reinstall multipass but it didn’t work and I also tried to use a virtual machine (ubuntu 20.04) and I received the same error again.

Thanks everyone in advance.

The error message originates from Snapcraft. Have you tried running it without sudo like the error message suggests?

I have the same problem, also with a project that was building before. Also tried to not use sudo, but then a PermissionError comes out.

This is the reason we did this as you would run once with sudo and have your home directory structure with different ownership Call for testing: Snapcraft 4.0

If any of the PermissionError you get are in ~/.cache/snapcraft, ~/.local/share/snapcraft or ~/.config/snapcraft I would suggest to chown them back to $USER.

1 Like

Yes, I did. And unfortunately it gives me this:

Launching a VM.
launch failed: Downloaded image hash does not match
An error occurred with the instance when trying to launch with ‘multipass’: returned exit code 2.
Ensure that ‘multipass’ is setup correctly and try again.

I looked in the properties of ~/.cache/snapcraft, ~/.local/share/snapcraft and ~/.config/snapcraft and it seems I still own them.

What I tried:

sg daniel -c ‘snapcraft --use-lxd’

and after installing lxd it gave me:

Error: LXD still not running after 30s timeout (Get “http://unix.socket/1.0”: dial unix /var/snap/lxd/common/lxd/unix.socket: connect: permission denied)
Timeout reached waiting for LXD to start.

sudo usermod -a -G lxd my_user_name # ________this line worked
sudo snapcraft # _________keeps giving me the same error message

sg lxd -c ‘snapcraft’

I received:

Launching a VM.
launch failed: Downloaded image hash does not match
An error occurred with the instance when trying to launch with ‘multipass’: returned exit code 2.
Ensure that ‘multipass’ is setup correctly and try again.

sg lxd -c ‘snapcraft --use-lxd’

I received:

Launching a container.
Project base changed from None to ‘core18’, cleaning build instance.
An error occurred with the instance when trying to launch with ‘LXD’: No storage pool found. Please > create a new storage pool.
Ensure that ‘LXD’ is setup correctly and try again.

sg my_user_name -c ‘snapcraft’

I received:

Launching a VM.
Project base changed from None to ‘core18’, cleaning build instance.
delete failed: The following errors occurred:
instance “snapcraft-tic-tac-toe-x” does not exist
An error occurred with the instance when trying to delete with ‘multipass’: returned exit code 2.
Ensure that ‘multipass’ is setup correctly and try again.

For:

  1. you need to be in the LXD group.
  2. you added yourself to the lxd group but missing a “newgrp lxd” call or session restart.
  3. The sg lxd should not matter when using snapcraft with defaults
  4. If you want to use LXD, you may want to lxd init first.
  5. What if you retry this? Multipass released right after Snapcraft so it will be hard to pin point these issues, @Saviq any ideas on the Multipass side?

I’m newbie, so I don’t know much about what is and what does LXD. Is there a way of using snapcraft without LXD? Thanks for trying to help me :smiley:

To use without LXD, try without the --use-lxd.

You can avoid the sg stuff by logging out of your desktop and logging back in. Make sure to run lxd init --auto if you do choose to use LXD.

In the end running it without sudo became the correct answer, although in the beginning it wasn’t working. I only don’t know why, maybe because I changed my OS and the versions of multipass and snapcraft until it worked. Thank you all.

1 Like

This suggests something went wrong with the downloaded image. Trying again should help, assuming everythning’s in order with the network.

This, however, is IMO a Snapcraft bug - it should check whether there’s anything to clean before failing on multipass delete …, if there isn’t.