Snap build currently fails

I find that make snap (which just runs snapcraft) fails. This is due to snapcraft not exposing the environment variable $SNAPCRAFT_PART_INSTALL to the prime stage with core20. This variable is exposed for core18.

Here’s the problematic part of snap/snapcraft.yaml:

<snip />
    override-prime: |
      set -e
      snapcraftctl set-version $($SNAPCRAFT_PART_SRC/utilities/package-version)
      cd $cwd
      snapcraftctl prime
      $SNAPCRAFT_PART_INSTALL/usr/bin/python3 -m compileall -q .

The above fails with:

/bin/bash: line 41: SNAPCRAFT_PART_INSTALL: unbound variable

The problem would probably have been non-existent before the following commit which updated from core18 to core20. (And indeed I’ve tested the commit before and the issue isn’t present.)

commit a914db2a36964290b0a658e13327ba7d260e61fa
Author: Alberto Donato <>
Date:   Wed Aug 5 14:39:15 2020 +0000

    support maas (exclusively) on Ubuntu 20.04 (core20 for the snap)

I’ve raised that as a potential issue over at the snapcraft forum, but even if that was amended it’s kind of moot as /root/parts/maas/install/usr/bin/python3 (which is what $SNAPCRAFT_PART_INSTALL/usr/bin/python3 would resolve to) doesn’t exist. :slight_smile: I think that the line in snap/snapcraft.yaml should simply be changed to:

      python3 -m compileall -q .

What’s the best way to raise this as an issue? Is it to open a case in launchpad and submit a patch?

Now I’ve discovered that despite getting the snap built, my core20 targetted snap doesn’t work due to python3-django-piston3 being broken in core20/focal.

This problem seems to be known about and it was apparently fixed for MAAS (and indeed the 2.9.2 snap from the store targets core20 and it works). And indeed the snapcraft.yaml file in the official release is identical to mine.

I ran unsquashfs on the official snap and the manifest shows that a new version python3-django-piston3=0.4-2 is included, which is modified to support django2. My build includes python3-django-piston3=0.3~rc2-3ubuntu9 which is still broken.

How can I get this newer version so that I can get on with testing? Is there a MAAS package repository that I need to add to snapcraft so that it pulls this package in? @ltrager are you able to illuminate?

It’s proving to be quite difficult to contibute to MAAS when an internal build produces different results to one I build locally.

Ok, I’m an idiot. I didn’t have the MAAS_PPA installed. I know that gets installed with a make install-dependencies but I thought it was just for local builds; didn’t appreciate the fact that snapcraft will use that when building a snap (in --destructive-mode anyway). Learn something new every day.

Cheat sheet for anyone like me that’s struggling to get this built as a snap after modifications (tested on Ubuntu 20.04 using snapcraft 4.5.4, the current latest/stable):

  • Install build-essential and golang from apt
  • Run make install-dependencies
  • Confirm that the MAAS PPA is in /etc/apt/sources.list.d
  • Modify the override-prime stage of part maas in snap/snapcraft.yaml:
    • Before: $SNAPCRAFT_PART_INSTALL/usr/bin/python3 -m compileall -q .
    • After: python3 -m compileall -q .
  • Run make snap (and perhaps a make snap-clean before just to make sure everything is pristine)

This will successfully build a snap which works. Do not run snapcraft or snapcraft --use-lxd directly as that will use multipass or LXD which will fail due to those modes of snapcraft not supporting additional repositories. Only snapcraft --destrictive-mode which is the one invoked by make snap works.

1 Like

hi @forky2, sorry you ran into this error, and thanks for your writeup.

Have you been building the snap from master?
The issue with the missing $SNAPCRAFT_PART_INSTALL var has been fixed in, so if you udpate your repo to a recent version you shoudn’t see the issue anymore.

Additionally, to build from master you need to have the latest-deps PPA ( enabled since the snaps needs to pull more recent versions of some packages than what’s available in Focal repositories.

Hope that clarifies things.

1 Like

Actually, @forky2, you’re not an idiot by any stretch of the imagination. Just wanted to take issue with that part of your post. :slight_smile:

I seriously appreciate you adding this to the discourse and taking the time to figure this out, before we could even get to you. Well done.

1 Like

Thanks @ack. Didn’t realise I was building an old version. Think it’s my fault for pulling from github instead of launchpad.

@billwear, it’s nice of you to say that, but I think I’m definitely making some daft mistakes at the moment. If I had taken the latest code as @ack pointed out, I wouldn’t have been having these issues. :slight_smile: Think I’m burnt out and need a holiday.

Anyway, the end result is good. I can build a MAAS snap for 2.9.2 fine, and I’ll be able to make changes to use in production.

Thanks all.

One final addendum. If anyone is trying to build an earlier tag (e.g. 2.9.2), an update to the go snap yesterday also broke the build. :slight_smile: Building make snap will produce following error:

package machine-resources is not in GOROOT (/snap/go/7221/src/machine-resources)
package machine-resources is not in GOROOT (/snap/go/7221/src/machine-resources)
package machine-resources is not in GOROOT (/snap/go/7221/src/machine-resources)
package machine-resources is not in GOROOT (/snap/go/7221/src/machine-resources)
make[1]: *** [Makefile:31: bin/i386] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [Makefile:31: bin/armhf] Error 1
make[1]: *** [Makefile:31: bin/amd64] Error 1
make[1]: *** [Makefile:31: bin/arm64] Error 1
make[1]: Leaving directory '/home/forky2/projects/maas-2.9.2-moonshot/parts/machine-resources/build'
Failed to build 'machine-resources'.

To resolve this, either run snap revert go or modify “go” under build-snaps in snap/snapcraft.yaml to be “go/1.15/stable”.

The master branch does not appear to be affected.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.