Skip to content

Systemd user session startup fails when WSL2 is already running. #888

@omasakun

Description

@omasakun

Bug description

When attempting to start the NixOS WSL2 distro while another distro is already running, the following error appears: wsl: Failed to start the systemd user session for ‘user01’. See journalctl for more details.

Checking with the top command confirms that the systemd --user process does not exist, and things like sops-nix do not function properly.

To Reproduce

Steps to reproduce the behavior:

  1. Set up the nixos-wsl distribution
  2. wsl --shutdown
  3. wsl -d <other-distro> : Start other distribution (e.g., wsl -d ubuntu-2004)
  4. wsl -d <nixos-distro> : Start the NixOS distribution (e.g., wsl -d tinynix)

An example of a small setup with sops-nix for repro: omasakun/tinynix-config

Notes

This issue did not occur when networking.hostName was not set in flake.nix or similar.

The hostname config seems to be related to the bug.

Logs

Outputs of journalctl

  • when the bug occurred (when ubuntu distro was already started): failed
  • when it did not occur (when no other distros were started): success

WSL version

WSL version: 2.6.1.0
Kernel version: 6.6.87.2-1
WSLg version: 1.0.66
MSRDC version: 1.2.6353
Direct3D version: 1.611.1-81528511
DXCore version: 10.0.26100.1-240331-1435.ge-release
Windows version: 10.0.26200.7171

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions