Snapd broken in LXD container on WSL2

Bug #1995083 reported by Edu Gómez Escandell
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
snapd
Fix Released
Undecided
Edu Gómez Escandell

Bug Description

This was the report that made me investigate:
https://github.com/ubuntu/WSL/issues/299#issuecomment-1294232561

The issue is that snapd correctly identifies that it is running on WSL, but cannot detect it is running on WSL2 so it falls back to thinking it is running on WSL1. The issue happens here:
https://github.com/snapcore/snapd/blob/3c05e535e5cff4b64e4427e38494795fbbfd5122/release/release.go#L140

In particular, this happens because WSL2 is detected by finding when the root filesystem is of type ext, but on LXC it is btrfs.

Once snapd thinks it is running on WSL1, it refuses to perform any action:
# snap list
Interacting with snapd is not yet supported on Windows Subsystem for Linux 1.
This command has been left available for documentation purposes only.

Tags: wsl
description: updated
Changed in snapd:
assignee: nobody → Edu Gómez Escandell (edugomez)
Revision history for this message
Edu Gómez Escandell (edugomez) wrote :

In order to replicate, start a distro in Ubuntu WSL2 with systemd enabled:
$ sudo lxd init # if necessary
...
$ sudo lxc launch ubuntu:jammy testcontainer
...
$ sudo lxc exec testcontainer -- bash
...
# apt update && apt upgrade snapd
...
# snap list
Interacting with snapd is not yet supported on Windows Subsystem for Linux 1.
This command has been left available for documentation purposes only.

description: updated
Revision history for this message
Edu Gómez Escandell (edugomez) wrote :
Changed in snapd:
status: New → In Progress
Changed in snapd:
status: In Progress → Fix Committed
Changed in snapd:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.