Setup snapd for snapcraft_legacy providers
Metadata
Current evaluation
Merged #3962 as 6122e30fd, adding craft-providers-style snapd setup for snapcraft_legacy LXD containers so /run/snapd.socket is available during core18 spread tests.
Resolution: closed resolved
Reason: PR #3962 was approved and merged as commit 6122e30fd. It initializes and starts snapd in snapcraft_legacy containers, resolving the missing /run/snapd.socket failure.
Evaluated by: mr-cal-bot
No scores available.
Issue body
- [X] Have you followed the [guidelines for contributing](https://github.com/snapcore/snapcraft/blob/master/CONTRIBUTING.md)?
- [X] Have you signed the [CLA](http://www.ubuntu.com/legal/contributors/)?
- [X] Have you successfully run `make lint`?
- [X] Have you successfully run `pytest tests/unit`?
-----
## Issue
A spread test on core18 started [consistently failing](https://github.com/snapcore/snapcraft/actions/runs/3329677836/jobs/5510607616) today.
The error is:
```
+ sudo -iu ubuntu env -i PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/snap/bin bash -c 'cd /snapcraft/tests/spread/plugins/v2/snaps/make-hello && snapcraft try --use-lxd'
Launching a container.
Waiting for container to be ready
Waiting for network to be ready...
error: cannot communicate with server: Put http://localhost/v2/snaps/system/conf: dial unix /run/snapd.socket: connect: no such file or directory
Starting Snapcraft 7.2.1.post6+git822e6686
Logging execution to '/home/ubuntu/.cache/snapcraft/log/snapcraft-20221026-173239.952534.log'
An error occurred when trying to execute 'snap unset system proxy.http' with 'LXD': returned exit code 1.
```
I'm not sure why the snapd socket isn't open. I wonder if it's due to an update to snapd. Snapcraft_legacy injects a copy of snapd from the host into the container. It's currently injecting snapd v`2.57.5`. I'm not sure why it's failing only on this particular spread test that calls `snapcraft try`.
## Solution
I copied the [snapd setup code](https://github.com/canonical/craft-providers/blob/ab325f27215ae669e6a9f41c507fa79a28f33b19/craft_providers/bases/buildd.py#L695) from `craft-providers`, which appears to solve the problem. (Although a `sleep()` function fixes the error too, the `craft-providers` code is a safer solution)
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Merged #3962 as 6122e30fd, adding craft-providers-style snapd setup for snapcraft_legacy LXD containers so /run/snapd.socket is available during core18 spread tests. | |
| stealth/space-bunny-alpha | — | closed resolved | PR merged as commit 6122e30fd: snapcraft_legacy LXD providers now run a craft-providers-style snapd setup (copy snapd, start snapd.service) so /run/snapd.socket exists, fixing the core18 spread test failure. | |
| stealth/space-bunny-alpha | — | closed resolved | Merged #3962 as 6122e30fd, adding craft-providers-style snapd setup so snapcraft_legacy LXD containers start snapd and expose /run/snapd.socket, fixing the core18 spread failure. | |
| qwen/qwen3.6-35b-a3b | — | — | Merged a fix for failing spread tests caused by missing snapd sockets in LXD containers. The change adopts snapd initialization logic from craft-providers to properly start the service, resolving connection errors. Approved and passed CI. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Merged a fix for failing core18 spread tests by initializing snapd in LXD containers for snapcraft_legacy providers. Adopted snapd setup logic from craft-providers to resolve socket connection errors. |
Update history
No update history recorded yet.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #3903 providers: choose legacy default provider from snap config | snapcraft | merged | Merged in snapcore/snapcraft#3903 as 59bc024, adding snapd-configurable LXD or Multipass selection for the snapcraft_legacy default provider. | |
| #3660 providers: integrate craft-providers support | snapcraft | merged | PR #3660 by cmatsuoka integrated craft-providers into Snapcraft, running lifecycle commands in LXD/Multipass instances. Merged into the 7.0 line via merge commit 7c2ac0027 (squash commit 8a06cdbbd). | |
| #1364 lxd: Inject snapcraft and core snaps into the container | snapcraft | merged | Merged PR #1364 as 99f5598ac, injecting the host's Snapcraft and core snaps into LXD containers so builds no longer use a mismatched Xenial archive version. | |
| #3943 providers: use new craft-providers interface | snapcraft | merged | Merged into snapcraft main as commit 2980d145c: removed in-tree Provider/LXDProvider/MultipassProvider classes in favour of craft-providers, and moved snapcraft/providers/providers.py to snapcraft/providers.py (+65/-1173). | |
| #709 Upstream snap hooks | craft-providers | closed | Centralized upstream snap hooks in craft-providers via merged PR #710 (commit 5bbaf39), shipping in 2.2.0 as reusable LXD cleanup utilities. |