{"record":{"id":"7addfb6940426009","repo":"SubtitleEdit/subtitleedit","slug":"failed-to-start-llama-server","errorCode":null,"errorMessage":"Failed to start llama-server","messagePattern":"Failed to start llama-server","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"warning","filePath":"src/libuilogic/LlamaCpp/LlamaCppServerManager.cs","lineNumber":574,"sourceCode":"                // clients' cache_prompt this keeps repeated prompt prefixes (system prompt,\n                // rolling context) from being re-ingested every request. Auto-disables with a\n                // warning on models whose context cannot shift. Not combined with multimodal -\n                // vision chunks cannot be shifted.\n                psi.ArgumentList.Add(\"--cache-reuse\");\n                psi.ArgumentList.Add(\"256\");\n            }\n            if (model.NoJinja)\n            {\n                psi.ArgumentList.Add(\"--no-jinja\");\n            }\n            if (model.ChatTemplate != null)\n            {\n                psi.ArgumentList.Add(\"--chat-template\");\n                psi.ArgumentList.Add(model.ChatTemplate);\n            }\n\n            var process = Process.Start(psi)\n                ?? throw new InvalidOperationException(\"Failed to start llama-server\");\n\n            LogAction?.Invoke($\"llama-server starting - PID: {process.Id}, Cmd: {FormatLaunchCommand(exe, psi.ArgumentList)}\");\n\n            lock (_serverLog)\n            {\n                _serverLog.Clear();\n            }\n\n            process.ErrorDataReceived += (_, e) =>\n            {\n                if (e.Data != null)\n                {\n                    lock (_serverLog) _serverLog.AppendLine(e.Data);\n                }\n            };\n            process.OutputDataReceived += (_, e) =>\n            {\n                if (e.Data != null)","sourceCodeStart":556,"sourceCodeEnd":592,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/libuilogic/LlamaCpp/LlamaCppServerManager.cs#L556-L592","documentation":"InvalidOperationException thrown when Process.Start(psi) returns null. On modern .NET Process.Start effectively never returns null (it throws Win32Exception on launch failure), so this guard is defensive and almost unreachable in practice. The earlier File.Exists(exe) check already removed the most common launch failure.","triggerScenarios":"Process.Start returns null — only documented to happen when the ProcessStartInfo cannot launch a process at all (e.g. FileName is empty or a degenerate info). On .NET 6+ genuine launch failures surface as Win32Exception, not null.","commonSituations":"Almost never seen in the wild; if reported it is usually a framework/runtime edge case or a corrupted llama-server executable that the OS rejects at CreateProcess time.","solutions":["If you actually hit this, capture psi.FileName and re-run the same command in a shell to see the real OS error (which Process.Start normally surfaces as Win32Exception).","Verify the llama-server binary is a valid executable for the current platform (x64 vs arm64, executable bit on Linux).","On Linux, ensure execute permission: chmod +x on the resolved exe path.","As a last resort, update the .NET runtime — null returns were more plausible on very old framework versions."],"exampleFix":"// before\nvar process = Process.Start(psi)\n    ?? throw new InvalidOperationException(\"Failed to start llama-server\");\n\n// after\nProcess process;\ntry { process = Process.Start(psi) ?? throw new InvalidOperationException(\"Failed to start llama-server\"); }\ncatch (Win32Exception ex) { throw new InvalidOperationException($\"Failed to start llama-server ({psi.FileName}): {ex.Message}\", ex); }","handlingStrategy":"try-catch","validationCode":"if (!File.Exists(exe)) return Result.Fail($\"llama-server missing at {exe}\");\nif (Environment.OSVersion.Platform == PlatformID.Unix)\n    AssertUnixExecBit(exe);","typeGuard":"null","tryCatchPattern":"Process process;\ntry { process = Process.Start(psi) ?? throw new InvalidOperationException(\"Failed to start llama-server\"); }\ncatch (Win32Exception ex) { throw new InvalidOperationException($\"Launch failed for {psi.FileName}: {ex.Message}\", ex); }\ncatch (PlatformNotSupportedException ex) { throw new InvalidOperationException(\"Process launch unsupported on this platform.\", ex); }","preventionTips":["Verify the executable is a valid binary for the OS/arch before launching.","On Unix, chmod +x the resolved exe path during install.","Always include the exe path in any launch-failure exception."],"tags":["llama-cpp","process","unreachable","defensive"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}