{"record":{"id":"f2a8084c4551e29e","repo":"SubtitleEdit/subtitleedit","slug":"llama-server-executable-not-found-please-downloa","errorCode":null,"errorMessage":"llama-server executable not found - please download llama.cpp first.","messagePattern":"llama-server executable not found - please download llama\\.cpp first\\.","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"src/libuilogic/LlamaCpp/LlamaCppServerManager.cs","lineNumber":501,"sourceCode":"        await ServerLock.WaitAsync(cancellationToken);\n        try\n        {\n            if (IsServerRunning && _serverModelPath == modelPath && _serverContextSize == contextSize)\n            {\n                Configuration.Settings.Tools.LlamaCppApiUrl = ApiUrl;\n                return;\n            }\n\n            // Server not running, or running with a different model - (re)start.\n            if (_serverProcess != null)\n            {\n                StopServerInternal();\n            }\n\n            var exe = GetExecutable();\n            if (!File.Exists(exe))\n            {\n                throw new FileNotFoundException(\"llama-server executable not found - please download llama.cpp first.\", exe);\n            }\n\n            if (!File.Exists(modelPath))\n            {\n                throw new FileNotFoundException(\"llama.cpp model not found - please download a model first.\", modelPath);\n            }\n\n            string? mmprojPath = null;\n            if (model.MmprojFileName != null)\n            {\n                mmprojPath = GetModelPath(model.MmprojFileName);\n                if (!File.Exists(mmprojPath))\n                {\n                    throw new FileNotFoundException(\"llama.cpp vision projector not found - please download the model first.\", mmprojPath);\n                }\n            }\n\n            var port = FindFreeLoopbackPort();","sourceCodeStart":483,"sourceCodeEnd":519,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/libuilogic/LlamaCpp/LlamaCppServerManager.cs#L483-L519","documentation":"Thrown by LlamaCppServerManager.EnsureServerRunningAsync when the llama-server executable does not exist on disk. GetExecutable() returns either an override path (ExecutableOverride) or <pluginsFolder>/llama-server[.exe]; File.Exists returns false. The exception is a FileNotFoundException carrying the resolved path, and the message tells the user to download llama.cpp first.","triggerScenarios":"EnsureServerRunningAsync is called to (re)start the local llama.cpp server for LLM-based translation; IsEngineInstalled() would already be false; the code proceeds to File.Exists(exe) at LlamaCppServerManager.cs:499 and it returns false. Triggered the first time a user picks an LLM engine without having downloaded llama.cpp, or after the plugin folder was cleaned/moved.","commonSituations":"First use of an LLM translator without running the llama.cpp download; plugin folder reset/deleted; ExecutableOverride pointing at a path that no longer exists (e.g. a USB drive or a previous install location); platform mismatch (expecting llama-server.exe on Linux).","solutions":["Run the in-app llama.cpp download (which places llama-server in GetAndCreateFolder()) before using an LLM engine.","If using a custom build, set ExecutableOverride to its absolute path.","Verify the file exists at the path in the exception (File.Exists on it).","Ensure the file is executable on Linux/macOS (chmod +x) and the right binary for the OS/architecture."],"exampleFix":"// before\nvar exe = GetExecutable();\nif (!File.Exists(exe))\n{\n    throw new FileNotFoundException(\"llama-server executable not found - please download llama.cpp first.\", exe);\n}\n\n// after - gate on IsEngineInstalled so callers can offer a download prompt instead of throwing, and hint at the override\nvar exe = GetExecutable();\nif (!File.Exists(exe))\n{\n    throw new FileNotFoundException($\"llama-server executable not found at '{exe}'. Download llama.cpp via the engine settings, or set ExecutableOverride to your build. Looked in: {GetAndCreateFolder()}\", exe);\n}","handlingStrategy":"validation","validationCode":"// Check engine presence before attempting to start the server\nvar exe = LlamaCppServerManager.GetExecutable();\nif (!File.Exists(exe))\n{\n    // Surface a clear, actionable prompt rather than letting Translate throw FileNotFoundException\n    throw new InvalidOperationException($\"llama.cpp is not installed. Resolved path '{exe}' does not exist. Download it via the engine settings or set ExecutableOverride.\");\n}\n// On Linux/macOS confirm it is executable\nif (!OperatingSystem.IsWindows())\n{\n    var mode = new System.IO.FileInfo(exe).Attributes; // attributes alone won't show +x; check via chmod if needed\n}","typeGuard":"public static bool IsLlamaCppInstalled() => File.Exists(LlamaCppServerManager.GetExecutable());","tryCatchPattern":"try\n{\n    await LlamaCppServerManager.EnsureServerRunningAsync(model, token);\n}\ncatch (FileNotFoundException ex) when (ex.Message.Contains(\"llama-server executable not found\"))\n{\n    // Prompt the user to download llama.cpp, then retry; or fall back to another engine\n    throw new InvalidOperationException(\"llama.cpp engine is missing. Download it from the engine settings and retry.\", ex);\n}","preventionTips":["Gate LLM engine use behind IsEngineInstalled() so the UI can prompt for a download before throwing.","Set ExecutableOverride when using a custom/own llama.cpp build, and validate it on save.","On Linux/macOS, ensure the binary is chmod +x after download.","Re-validate the executable path after plugin folder moves or upgrades."],"tags":["filesystem","external-tool","configuration","llama-cpp","translation"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}