Build providers

This feature is added back in 3.10, however, Snapcraft developers have made clear that undocumented environment variable usage is unsupported. Feel free to use it but do not expect it’ll always work.

UPDATE: Refer @cjp256’s reply below.

I’ve updated the doc Build options to document SNAPCRAFT_BUILD_ENVIRONMENT=lxd and moved lxd out of “Development” status.

2 Likes

I just noticed that this page is not in the list of pages on the “docs” page; instead, it seems to be accessed solely via a link partway down this page: https://snapcraft.io/docs/build-options, which would naturally make it harder to find. Should all docs pages have their own entry in the ToC list on the main “docs” page?

Ideally, I think they should - yes. We’ve not been able to for a few reasons - conflicting opinions, and because the doc set is too large (450+ pages) and we have nothing to make the resultant ToC more manageable, such as folding. This is something we’re finally looking into, and I hope we can improve the navigation in the near future.

I will add this page, though, as it’s important (thanks!) - it’s the way I build snaps, and I’m sure its the same for many people.

If you’re looking for collapsible/expandable docs, check out the current format for online docs at Yocto Project:

It’s based on Sphinx and, unhumbly, I was one of the people who helped set it up in the early days, and I still work on those docs. The best part: foldable ToC.

Check out the full source at https://git.yoctoproject.org/yocto-docs/

1 Like

I was unsure about whether LXD should be installed via snap or whether installing via .deb was adequate, and Oliver G explained:

“the deb just installs the snap … (there is no actual deb any more) … I’d go directly for the snap instead so you dont have that transitional package cruft in the deb database …”

Perhaps that clarification could be added to this page.

1 Like

There’s been some improvements to how snapcraft interfaces with providers that I’d like to document. Notably:

  1. core22 snaps use lxd by default when building on linux systems
  2. The default provider can be configured with snap set provider=<provider>
  3. snapcraft will ask the user if it can install lxd or multipass

I believe this page is the right place, but rather than just focusing on lxd, I’d like to broaden it to talking about lxd, multipass, and how to configure snapcraft to choose one or the other.

Any concerns with me renaming this page from “Build on LXD” to something like “Building with LXD and Multipass”?

↑ bump @degville.

If it’s OK with you, I’m going to rename and expand this doc!

Hello - and yes, of course. Please feel free to change/update anything at all.

Updated! I don’t have permissions to rename the page. Can you rename it to “Building with LXD and Multipass”? Or if that is too verbose, then “Build Providers”?

Also, I think this page should be moved in the documentation’s navigation menu to sit next to the “Build Options” section.

I’ve renamed it and moved it in the navigation. I also set up a redirect for the old URL. Thanks so much for making those changes and the name change/location suggestions.

2 Likes

Hi.

Out of curiosity, now that this option is gone with core22, is there any other approach when using Multipass to change the available resources ?

Cheers, Just

1 Like

Hi @jocado,

Currently, there is no way to override these settings for core22 snaps. Multipass instances are hardcoded to 2GB memory and 2 CPUs.

Would you please file an issue in launchpad?

Sure - bug created: Bug #2008003 “Multipass build provider does not support resource...” : Bugs : Snapcraft

:+1:

Cheers, Just

2 Likes

Does “–provider” even work anymore? I just tried it and got:

$ snapcraft --provider=host Option --provider is not supported.
Full execution log: ‘/home/rpjday/.local/state/snapcraft/log/snapcraft-20230618-064154.748184.log’ $

And “snapcraft build --help” doesn’t list --provider as a valid option.

Is this when using core22 ? I get the same error when trying --provider with a core22 build, but we do try to document this above with the base distinctions (and you’re right about the help output).

I’m looking at the code and it’s not clear that that option is even supported anymore.

Snapcraft 7 deprecated the --provider option. It is not supported for core22 snaps. Although it still works for core18|20 snaps, it is no longer shown in help messages.

The precedence for selecting the provider as listed here, https://snapcraft.io/docs/build-providers, is wrong with SC7; I have already submitted a bug, https://github.com/snapcore/snapcraft/issues/4307

1 Like

There is apparently a PR in the works for this, so I can think we can treat this as resolved.

2 Likes