chenhg5/cc-connect · error
systemd user session not available in WSL2. Add the follow
Error message
systemd user session not available in WSL2.
Add the following to /etc/wsl.conf and restart WSL (wsl --shutdown):
[boot]
systemd=true
Or use: nohup cc-connect > cc-connect.log 2>&1 & What it means
On WSL2, cc-connect's daemon support needs systemd's user session (systemctl --user) to manage the service. This error is thrown when the WSL2 check in checkSystemdRunning determines the user-level systemd session is not available — almost always because systemd is disabled in /etc/wsl.conf. The message contains the exact wsl.conf snippet needed to enable it.
Source
Thrown at daemon/systemd.go:294
return fmt.Errorf("systemd is not active in this WSL2 instance.\n" +
" Add the following to /etc/wsl.conf and restart WSL (wsl --shutdown):\n" +
" [boot]\n" +
" systemd=true\n" +
" Or use: nohup cc-connect > cc-connect.log 2>&1 &")
}
if state == "offline" || strings.Contains(state, "not been booted") {
return fmt.Errorf("systemd is not active (state: %s).\n"+
" If running in a container, systemd is typically not available.\n"+
" Use nohup, tmux, or screen instead:\n"+
" nohup cc-connect > cc-connect.log 2>&1 &", state)
}
return fmt.Errorf("systemd check failed (state: %s).\n"+
" Use nohup as alternative: nohup cc-connect > cc-connect.log 2>&1 &", state)
}
// User-level failures
if wsl {
return fmt.Errorf("systemd user session not available in WSL2.\n" +
" Add the following to /etc/wsl.conf and restart WSL (wsl --shutdown):\n" +
" [boot]\n" +
" systemd=true\n" +
" Or use: nohup cc-connect > cc-connect.log 2>&1 &")
}
user := os.Getenv("USER")
return fmt.Errorf("systemd user session not available.\n"+
" This often happens when connecting via SSH without a systemd login session.\n"+
" Try one of:\n"+
" 1. Run as root: sudo cc-connect daemon install (uses system-level systemd)\n"+
" 2. loginctl enable-linger %s && export XDG_RUNTIME_DIR=/run/user/$(id -u)\n"+
" 3. Use nohup/tmux instead: nohup cc-connect > cc-connect.log 2>&1 &", user)
}
func isWSL2() bool {
data, err := os.ReadFile("/proc/version")
if err != nil {View on GitHub (pinned to 4000b2338a)
Solutions
- Add the following to /etc/wsl.conf: [boot] systemd=true then restart WSL with `wsl --shutdown` and reopen your distro
- Verify afterwards: `systemctl is-system-running` and `systemctl --user status` both respond
- Require a recent WSL version (`wsl --update`) since systemd support needs WSL 0.67.6+ / Windows 11 or backported support
- If you cannot enable systemd, use `nohup cc-connect > cc-connect.log 2>&1 &` instead of the daemon subcommand
Example fix
// before: /etc/wsl.conf without systemd // after: $ sudo tee -a /etc/wsl.conf >/dev/null <<'EOF' [boot] systemd=true EOF $ wsl --shutdown # from PowerShell, then reopen WSL $ cc-connect daemon install
Defensive patterns
Strategy: validation
Validate before calling
if grep -qs '^\[boot\]' /etc/wsl.conf && grep -qsA1 '^\[boot\]' /etc/wsl.conf | grep -qs 'systemd=true'; then cc-connect daemon install else echo "Enable systemd in /etc/wsl.conf ([boot] systemd=true), run 'wsl --shutdown', then retry" fi
Try / catch
if err := daemon.Install(cfg); err != nil && strings.Contains(err.Error(), "WSL2") {
fmt.Fprintln(os.Stderr, "Enable systemd: add '[boot]\nsystemd=true' to /etc/wsl.conf, then run 'wsl --shutdown'")
os.Exit(1)
} Prevention
- Enable systemd=true in /etc/wsl.conf immediately after installing any WSL distro you plan to run services in
- Pin a recent WSL version (`wsl --update`) since systemd support requires WSL >= 0.67.6
- After every `wsl --shutdown`, verify `systemctl --user status` works before running daemon commands
- Automate WSL provisioning with a check for /etc/wsl.conf systemd=true
When it happens
Trigger: Running `cc-connect daemon install` inside WSL2 where /etc/wsl.conf lacks the `[boot] systemd=true` directive, so `systemctl --user` has no user session/manager to talk to.
Common situations: Default WSL2 distributions (systemd is off by default on older WSL releases); freshly installed WSL distros where wsl.conf was never edited; users who enabled system-level systemd but not the user session.
Related errors
- systemd is not active in this WSL2 instance. Add the follo
- systemd is not active (state: %s). If running in a contain
- systemd check failed (state: %s). Use nohup as alternative
- taskkill failed: %w: %s
- taskkill failed: %w: %s; process kill fallback failed: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/8399e32bf5175dd6.
Report an issue: GitHub.