Snapcraft returns exit code 255 when following ros tutorial

Hi there

Brand new to snaps and to the forum

I’m following the offical ros talker listener tutorial. When I run snapcraft inside the build directory (over the snapcraft.yaml) I get the following error.

An error occurred when trying to execute ‘sudo -H -i env SNAPCRAFT_BUILD_ENVIRONMENT=managed-host HOME=/root SNAPCRAFT_HAS_TTY=True apt-get dist-upgrade --yes’ with ‘multipass’: returned exit code 255.

I am currently running multipass --edge on ubuntu 18.04. I was able to build (I think) the C++ dos example. Multipass list returns

snapcraft-test-dosbox-eoinnocs Running 10.25.71.138 Ubuntu Snapcraft builder for Core 18
snapcraft-test-ros-talker-listener-eoinnocs Running 10.25.71.138 Ubuntu Snapcraft builder for Core 18

I suppose I have two questions. One is how to I do I fix the build issue. Two is, my understanding was that snapcraft spins up a VM for building and tears it down afterwards, so why are both VMs still running?

So after some fiddling, reinstalling the stable version and an error where dirmngr wasn’t installed inside the multipass environment. The error message when away on it’s own.

I’ve learned that running sudo snapcraft is a bad idea because it messes with multipass.

The original problem that I got in the tutorial was actually about the build environment being unable to verify the ROS GPG key due to not having dirmngr installed. This looks to be a know bug inside snapcraft 4.3. I was able to enter the multipass build environment by calling snapcraft --debug, manually install dirmngr and call snapcraft inside the VM.

I had a similar issue and received the same exit code:

An error occurred when trying to execute 'sudo -H -i env SNAPCRAFT_BUILD_ENVIRONMENT=managed-host HOME=/root SNAPCRAFT_HAS_TTY=True apt-get dist-upgrade --yes' with 'multipass': returned exit code 255.

I didn’t manually install dirmngr, but I added it to the build-packages in snapcraft.yaml and that seems to work.

Has there been a bug submitted for this?

I’m having this exact problem attempting to build the C++ DosBox example on Ubuntu 20.

How do I debug multipass errors to determine how to fix this?