{"record":{"id":"0c0f1456ff883ef9","repo":"chenhg5/cc-connect","slug":"systemd-is-not-active-state-s-if-running-in","errorCode":null,"errorMessage":"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 &","messagePattern":"systemd is not active \\(state: (.+?)\\)\\.\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 &","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"daemon/systemd.go","lineNumber":283,"sourceCode":"\tswitch state {\n\tcase \"running\", \"degraded\", \"starting\", \"initializing\":\n\t\treturn nil\n\t}\n\n\t// \"offline\" = systemd exists but is not PID 1 (WSL2 without systemd, some containers)\n\t// \"not been booted\" / empty = no systemd at all\n\twsl := isWSL2()\n\n\tif system {\n\t\tif wsl {\n\t\t\treturn fmt.Errorf(\"systemd is not active in this WSL2 instance.\\n\" +\n\t\t\t\t\"  Add the following to /etc/wsl.conf and restart WSL (wsl --shutdown):\\n\" +\n\t\t\t\t\"    [boot]\\n\" +\n\t\t\t\t\"    systemd=true\\n\" +\n\t\t\t\t\"  Or use: nohup cc-connect > cc-connect.log 2>&1 &\")\n\t\t}\n\t\tif state == \"offline\" || strings.Contains(state, \"not been booted\") {\n\t\t\treturn fmt.Errorf(\"systemd is not active (state: %s).\\n\"+\n\t\t\t\t\"  If running in a container, systemd is typically not available.\\n\"+\n\t\t\t\t\"  Use nohup, tmux, or screen instead:\\n\"+\n\t\t\t\t\"    nohup cc-connect > cc-connect.log 2>&1 &\", state)\n\t\t}\n\t\treturn fmt.Errorf(\"systemd check failed (state: %s).\\n\"+\n\t\t\t\"  Use nohup as alternative: nohup cc-connect > cc-connect.log 2>&1 &\", state)\n\t}\n\n\t// User-level failures\n\tif wsl {\n\t\treturn fmt.Errorf(\"systemd user session not available in WSL2.\\n\" +\n\t\t\t\"  Add the following to /etc/wsl.conf and restart WSL (wsl --shutdown):\\n\" +\n\t\t\t\"    [boot]\\n\" +\n\t\t\t\"    systemd=true\\n\" +\n\t\t\t\"  Or use: nohup cc-connect > cc-connect.log 2>&1 &\")\n\t}\n\n\tuser := os.Getenv(\"USER\")","sourceCodeStart":265,"sourceCodeEnd":301,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/daemon/systemd.go#L265-L301","documentation":"cc-connect's daemon management on Linux requires systemd, which it verifies via checkSystemdRunning before returning a platform Manager from newPlatformManager. This error is thrown when the systemd state query succeeds but reports the system bus is not active (e.g. state \"offline\" or \"System has not been booted with systemd\"). It means PID 1 is not systemd, so systemctl/unit management cannot work. The error message explicitly suggests nohup/tmux/screen as alternatives because containers and minimal environments typically lack systemd.","triggerScenarios":"Running `cc-connect daemon install` (or any daemon subcommand) on a machine where `systemctl is-system-running` returns \"offline\" or a state containing \"not been booted\" — typically inside a Docker/container without systemd as PID 1.","commonSituations":"Running cc-connect inside a Docker container or Kubernetes pod; a minimal chroot; WSL1; environments where systemd was replaced (e.g. runit/OpenRC systems).","solutions":["Do not use the daemon subcommand in this environment; run cc-connect directly in the background: `nohup cc-connect > cc-connect.log 2>&1 &`","Use tmux or screen: `tmux new -d -s cc-connect 'cc-connect'`","If in Docker and you need systemd, run the container with systemd as PID 1 (e.g. `--privileged` with a systemd-enabled image) or use a host-side supervisor instead","On a real Linux host, boot with systemd as init and confirm with `ps -p 1 -o comm=` showing `systemd`"],"exampleFix":"// before: `cc-connect daemon install` inside a Docker container\n// fails with \"systemd is not active (state: offline)\"\n// after: run without daemon management\n$ nohup cc-connect > cc-connect.log 2>&1 &\n// or in CI/docker-compose use restart policies instead of an internal daemon","handlingStrategy":"fallback","validationCode":"state := $(systemctl is-system-running 2>/dev/null)\nif [ \"$state\" != \"running\" ]; then\n  echo \"systemd unavailable (state=$state); using nohup fallback\"\n  nohup cc-connect > cc-connect.log 2>&1 &\nelse\n  cc-connect daemon install\nfi","typeGuard":null,"tryCatchPattern":"mgr, err := daemon.NewPlatformManager()\nif err != nil {\n    slog.Warn(\"daemon manager unavailable, falling back to foreground mode\", \"error\", err)\n    return runForeground(ctx)\n}","preventionTips":["Detect containers before using daemon subcommands (check /.dockerenv or systemd state) and document a nohup/tmux runbook for them","In Docker deployments, use restart policies or a host supervisor instead of in-container daemon management","Script the fallback: attempt daemon install, and on failure launch cc-connect with nohup automatically","Verify `ps -p 1 -o comm=` shows systemd on hosts where you plan to use daemon management"],"tags":["daemon","systemd","linux","containers","process-management"],"backgroundTag":"systemd-unavailable","analyzedSha":"4000b2338aa6e850c99df54f8b0ed6ed7460b401","analyzedAt":"2026-09-06T11:45:09.575Z","contentChangedAt":"2026-09-06T11:45:09.575Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}