Environment variables that Snapcraft consumes

NOTE:

  • This table is NOT complete nor error-free, feel free to extend/fix it.
  • Environment variables are mostly for experimental/internal usage and shouldn’t be considered stable
Name & Description Typical Values
SNAPCRAFT_BUILD_ENVIRONMENT
Refer The SNAPCRAFT_BUILD_ENVIRONMENT environment variable for more info
[host|managed-host|multipass]
(The value lxd has been obsoleted in Snapcraft 3.0 new syntax)
SNAPCRAFT_BUILD_ENVIRONMENT_DISK
The allocated virtual storage size for the VM build environment
Default value: 256G
Source: snapcraft/_multipass.py at 9d353a6305b8006e0bc0e984c87591e5f08fb09d · snapcore/snapcraft
NOTE: This environment variable is only honored when the VM is not created yet
256G
SNAPCRAFT_BUILD_ENVIRONMENT_CPU
The allocated processor cores for the VM build environment
Default value: 2
Source: snapcraft/_multipass.py at 9d353a6305b8006e0bc0e984c87591e5f08fb09d · snapcore/snapcraft
NOTE: This environment variable is only honored when the VM is not created yet
2
SNAPCRAFT_BUILD_ENVIRONMENT_MEMORY
The allocated primary memory size for the VM build environment
Default value: 4G
Source: snapcraft/_multipass.py at 9d353a6305b8006e0bc0e984c87591e5f08fb09d · snapcore/snapcraft
NOTE: This environment variable is only honored when the VM is not created yet
2G
(Should be the same argument of multipass launch --mem, amount of memory to allocate in bytes, or with K, M, G suffix)
SNAPCRAFT_ENABLE_DEVELOPER_DEBUG
Enable verbose debugging messages, refer Debugging snapcraft for more info
[y|yes|t|true|on|1|n|no|f|false|off|0]
(A Python distutils.util.strtobool boolean value) (source)
2 Likes

@admins, I forget to set this topic as wiki, can one of you help me out?

@admins reping…

Oops - sorry for missing this before. It’s a wiki now. Thank you!

1 Like

Thank you.

However, when I set this one to, say, 8G:

It seems to be ignored. In my process, I still see qmey consuming 2G.

EDIT: nevermind, it just requires snapcraft clean beforehand.

1 Like

I was going the note that here, but at the time this page is not editable. :slight_smile:

Can these settings be defined inside snapcraft.yml? If so, where? I need to this for reproducible builds.

I’m afraid that’s not possible, you may want to file a feature request to snapcore/snapcraft for that matter.

1 Like

Note that for snapcraft 7 + core22 building on lxd, this works to limit cpu cores: lxc profile set default --project snapcraft limits.cpu=2

Otherwise it uses all of all of your cores and then you can’t really do much else.

2 Likes

omg, Heather, that is an epic suggestion! I hate that when building a snap I can’t watch a yootoobe video at the same time without it stuttering when it gets to the snap phase (at the least, depending on the build it happens elsewhere, too)

2 Likes