{"record":{"id":"03fa3e58fa6ba7ab","repo":"chenhg5/cc-connect","slug":"systemctl-not-found-systemd-is-required-on-linux","errorCode":null,"errorMessage":"systemctl not found: systemd is required on Linux; if running in a container without systemd, use nohup, tmux, or screen instead","messagePattern":"systemctl not found: systemd is required on Linux; if running in a container without systemd, use nohup, tmux, or screen instead","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"daemon/systemd.go","lineNumber":26,"sourceCode":"\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n\t\"sort\"\n\t\"strconv\"\n\t\"strings\"\n)\n\nconst (\n\tsystemdServiceName = ServiceName + \".service\"\n)\n\ntype systemdManager struct {\n\tsystem bool // true = system-level (/etc/systemd/system), false = user-level (~/.config/systemd/user)\n}\n\nfunc newPlatformManager() (Manager, error) {\n\tif _, err := exec.LookPath(\"systemctl\"); err != nil {\n\t\treturn nil, fmt.Errorf(\"systemctl not found: systemd is required on Linux; if running in a container without systemd, use nohup, tmux, or screen instead\")\n\t}\n\n\tisRoot := os.Getuid() == 0\n\n\tif isRoot {\n\t\tif err := checkSystemdRunning(true); err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn &systemdManager{system: true}, nil\n\t}\n\n\tif err := checkSystemdRunning(false); err != nil {\n\t\treturn nil, err\n\t}\n\treturn &systemdManager{system: false}, nil\n}\n\nfunc (m *systemdManager) Platform() string {","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/chenhg5/cc-connect/blob/4000b2338aa6e850c99df54f8b0ed6ed7460b401/daemon/systemd.go#L8-L44","documentation":"On Linux, the daemon manager is systemd (newPlatformManager). Before creating the manager it checks that the `systemctl` binary exists via exec.LookPath; this error is returned when systemctl is not on PATH, meaning systemd-based service management cannot work.","triggerScenarios":"Running `cc-connect daemon install` (Linux path) inside a container or environment without systemd — no systemctl binary on PATH (e.g. plain Docker images, WSL1, chroots).","commonSituations":"Docker containers without systemd; minimal Alpine/scratch-based images; WSL without systemd enabled; older init systems (upstart, runit); CI runners.","solutions":["Run the daemon with nohup instead: `nohup cc-connect serve &`, as the error message suggests.","Use tmux or screen to keep the process alive: `tmux new -d 'cc-connect serve'`.","If in Docker, enable systemd in the container (e.g. systemd-enabled images or --privileged with /sbin/init) or install/enable systemd if using WSL2 (systemd=true in /etc/wsl.conf).","Install systemd/sysvinit tooling if the host should have it but PATH is stripped."],"exampleFix":"// before (container without systemd)\n$ cc-connect daemon install   # systemctl not found\n// after\n$ nohup cc-connect serve > ~/cc-connect.log 2>&1 &","handlingStrategy":"fallback","validationCode":"if runtime.GOOS == \"linux\" {\n    if _, err := exec.LookPath(\"systemctl\"); err != nil {\n        // environment has no systemd; choose nohup/tmux/screen path instead\n    }\n}","typeGuard":null,"tryCatchPattern":"_, err := daemon.NewManager() // via install path\nif err != nil {\n    if strings.Contains(err.Error(), \"systemctl not found\") {\n        // fall back to manual process management\n        exec.Command(\"sh\", \"-c\", \"nohup cc-connect serve &\").Start()\n        return nil\n    }\n    return err\n}","preventionTips":["Detect systemd availability before offering `daemon install` in scripts.","In containers, use nohup/tmux/screen or a proper supervisor instead of systemd.","On WSL2, enable systemd via /etc/wsl.conf ([boot] systemd=true).","Prefer distro images with systemd when service management is required."],"tags":["daemon","systemd","linux","container"],"backgroundTag":"command-not-found","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"}