{"record":{"id":"839b0a584cee8081","repo":"SubtitleEdit/subtitleedit","slug":"llama-cpp-model-not-found-please-download-a-mode","errorCode":null,"errorMessage":"llama.cpp model not found - please download a model first.","messagePattern":"llama\\.cpp model not found - please download a model first\\.","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"error","filePath":"src/libuilogic/LlamaCpp/LlamaCppServerManager.cs","lineNumber":506,"sourceCode":"                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();\n            var psi = new ProcessStartInfo\n            {\n                WorkingDirectory = Path.GetDirectoryName(exe) ?? GetAndCreateFolder(),\n                FileName = exe,\n                UseShellExecute = false,","sourceCodeStart":488,"sourceCodeEnd":524,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/libuilogic/LlamaCpp/LlamaCppServerManager.cs#L488-L524","documentation":"Thrown by LlamaCppServerManager when starting llama-server: the resolved modelPath (a .gguf file) does not exist on disk. It is a FileNotFoundException whose FileName is the missing path. The check happens AFTER the executable presence check, so reaching it means llama-server itself is present but the model weight file is not.","triggerScenarios":"Calling the server start path with a LlamaCppModel whose local file was deleted, moved, or never finished downloading; GetModelPath() resolving to a path under the SE models folder that no longer contains the .gguf.","commonSituations":"User picked a model in the SE GUI, then cleaned the Models folder; an interrupted download left a partial file that File.Exists rejects; antivirus quarantined the .gguf; the model file lives under %AppData% on a different user account.","solutions":["Re-download the model from Subtitle Edit (Auto-translate > llama.cpp > Download) so the .gguf lands in GetAndCreateModelsFolder().","Verify the resolved modelPath with File.Exists before calling StartServer and surface a user-facing message if it is missing.","If you keep models elsewhere, pass an absolute path via --translate-model:<path.gguf> so resolution skips the models folder.","Check for a half-written download (size far smaller than expected) and delete it so SE re-downloads."],"exampleFix":"// before\nif (!File.Exists(modelPath))\n    throw new FileNotFoundException(\"llama.cpp model not found - please download a model first.\", modelPath);\n\n// after (caller-side guard)\nif (!File.Exists(modelPath))\n    return Result.Fail($\"Model not found at '{modelPath}'. Download it via SE Auto-translate > llama.cpp, or pass --translate-model.\");","handlingStrategy":"validation","validationCode":"public static void EnsureModelPresent(string modelPath)\n{\n    if (!File.Exists(modelPath))\n        throw new InvalidOperationException(\n            $\"Model '{modelPath}' is missing. Download via SE Auto-translate > llama.cpp.\");\n    var info = new FileInfo(modelPath);\n    if (info.Length < 1024 * 1024)\n        throw new InvalidOperationException($\"Model '{modelPath}' looks truncated ({info.Length} bytes).\");\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Call File.Exists on the resolved modelPath before invoking StartServer and surface a clear message.","After a download, verify the .gguf size matches the HuggingFace expected size to catch partial files.","Treat GetModelPath output as untrusted — log it once per run so mis-resolution is visible."],"tags":["llama-cpp","file-not-found","model-loading","configuration"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}