{"record":{"id":"d01320b7a653d195","repo":"MHSanaei/3x-ui","slug":"failed-to-start-panel-update-job-w-s","errorCode":null,"errorMessage":"failed to start panel update job: %w: %s","messagePattern":"failed to start panel update job: %w: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/web/service/panel/panel.go","lineNumber":269,"sourceCode":"\n\tif systemdRun, err := exec.LookPath(\"systemd-run\"); err == nil {\n\t\tunitName := fmt.Sprintf(\"x-ui-web-update-%d\", time.Now().Unix())\n\t\tcmd := exec.CommandContext(context.Background(), systemdRun,\n\t\t\t\"--unit\", unitName,\n\t\t\t\"--setenv\", \"XUI_MAIN_FOLDER=\"+mainFolder,\n\t\t\t\"--setenv\", \"XUI_SERVICE=\"+serviceFolder,\n\t\t\t\"--setenv\", \"XUI_UPDATE_TAG=\"+updateTag,\n\t\t\t\"--setenv\", runIDEnv,\n\t\t\t\"--setenv\", statusFileEnv,\n\t\t\tbash, \"-lc\", updateScript,\n\t\t)\n\t\tout, err := cmd.CombinedOutput()\n\t\tif err != nil {\n\t\t\toutput := strings.TrimSpace(string(out))\n\t\t\tif !strings.Contains(output, \"System has not been booted with systemd\") &&\n\t\t\t\t!strings.Contains(output, \"Failed to connect to bus\") {\n\t\t\t\t_ = os.Remove(scriptPath)\n\t\t\t\treturn 0, fmt.Errorf(\"failed to start panel update job: %w: %s\", err, output)\n\t\t\t}\n\t\t\tlogger.Warning(\"systemd-run is unavailable, falling back to detached update process:\", output)\n\t\t} else {\n\t\t\tlogger.Infof(\"started panel update job via systemd-run unit %s\", unitName)\n\t\t\tlaunched = true\n\t\t\treturn runID, nil\n\t\t}\n\t}\n\n\tcmd := exec.CommandContext(context.Background(), bash, \"-lc\", updateScript)\n\tcmd.Env = append(os.Environ(),\n\t\t\"XUI_MAIN_FOLDER=\"+mainFolder,\n\t\t\"XUI_SERVICE=\"+serviceFolder,\n\t\t\"XUI_UPDATE_TAG=\"+updateTag,\n\t\trunIDEnv,\n\t\tstatusFileEnv,\n\t)\n\tsetDetachedProcess(cmd)","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/MHSanaei/3x-ui/blob/ad32144c42455696ea9f14e12168beac3e25f5d2/internal/web/service/panel/panel.go#L251-L287","documentation":"The preferred launch path runs the updater under systemd-run (transient unit). If systemd-run exits non-zero AND its output does not contain the two known 'systemd not available' strings ('System has not been booted with systemd' / 'Failed to connect to bus'), the failure is treated as real: the script file is removed and the wrapped error plus systemd-run's combined output is returned. Known causes: SELinux/AppArmor denial, systemd-run version not supporting the used flags, resource limits on transient units.","triggerScenarios":"Triggering the update on a host where systemd exists but systemd-run fails for another reason — e.g. 'Failed to start transient service unit: ...' policy denial, or an embedded init with a systemd-run shim that errors oddly.","commonSituations":"Hardened systems (SELinux enforcing) blocking transient units; old systemd versions (<231) lacking --property/--setenv support variants; OpenRC/Void with a partial systemd compat layer producing unfamiliar errors.","solutions":["Read the appended output in the error message — it is systemd-run's stderr and names the real cause","If it is a policy denial, allow transient units for the panel user or adjust SELinux/AppArmor","As a workaround, run the official update script manually (same script the panel downloads), then restart the panel"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":"if out, err := exec.Command(\"systemd-run\", \"--version\").CombinedOutput(); err != nil {\n    // expect the detached-process fallback; if systemd IS present but this fails, investigate policy\n}","typeGuard":null,"tryCatchPattern":"_, err := panelService.StartUpdate(false)\nif err != nil && strings.Contains(err.Error(), \"failed to start panel update job\") {\n    // parse the appended systemd-run output; if policy denial, fix unit policy or update manually\n}","preventionTips":["Allow transient units for the panel service user on hardened hosts","Keep a known-good manual update command documented for fallback"],"tags":["systemd","updates","panel-update","environment","linux"],"backgroundTag":null,"analyzedSha":"ad32144c42455696ea9f14e12168beac3e25f5d2","analyzedAt":"2026-08-15T11:13:23.905Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}