{"record":{"id":"dd9958ba2a5c2224","repo":"SubtitleEdit/subtitleedit","slug":"translate-model-file-not-found-name","errorCode":null,"errorMessage":"Translate model file not found: {name}","messagePattern":"Translate model file not found: (.+?)","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/seconv/Core/AutoTranslateRunner.cs","lineNumber":219,"sourceCode":"    private static LlamaCppModel ResolveLocalLlamaCpp(string? requestedModel)\n    {\n        LlamaCppLocal.EnsureServerBinary(\"Auto-translate > llama.cpp\", \"--translate-url\");\n        return ResolveLlamaCppModel(requestedModel);\n    }\n\n    private static LlamaCppModel ResolveLlamaCppModel(string? requestedModel)\n    {\n        if (!string.IsNullOrWhiteSpace(requestedModel))\n        {\n            var name = requestedModel.Trim();\n\n            // Full path to a .gguf: use it directly, but infer the chat-template flags from the file\n            // name (TranslateGemma/Qwen need them, whether or not we curate that exact quant).\n            if (Path.IsPathRooted(name) || name.Contains(Path.DirectorySeparatorChar) || name.Contains(Path.AltDirectorySeparatorChar))\n            {\n                if (!File.Exists(name))\n                {\n                    throw new InvalidOperationException($\"Translate model file not found: {name}\");\n                }\n\n                var fileName = Path.GetFileName(name);\n                var (chatTemplate, noJinja) = LlamaCppServerManager.InferChatTemplate(fileName);\n                return new LlamaCppModel(fileName, Path.GetFullPath(name), string.Empty, Url: string.Empty,\n                    ChatTemplate: chatTemplate, NoJinja: noJinja);\n            }\n\n            // Name: match curated + custom models in the models folder (with or without .gguf).\n            var all = LlamaCppServerManager.GetAllTranslateModels();\n            var model = all.FirstOrDefault(m => m.FileName.Equals(name, StringComparison.OrdinalIgnoreCase))\n                        ?? all.FirstOrDefault(m => m.FileName.Equals(name + \".gguf\", StringComparison.OrdinalIgnoreCase))\n                        ?? all.FirstOrDefault(m => m.DisplayName.Equals(name, StringComparison.OrdinalIgnoreCase));\n            if (model == null || !LlamaCppServerManager.IsModelInstalled(model))\n            {\n                throw new InvalidOperationException(\n                    $\"Translate model '{name}' not found in {LlamaCppServerManager.GetAndCreateModelsFolder()}. \" +\n                    \"Download one in Subtitle Edit (Auto-translate > llama.cpp), drop a .gguf into that folder, \" +","sourceCodeStart":201,"sourceCodeEnd":237,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/seconv/Core/AutoTranslateRunner.cs#L201-L237","documentation":"InvalidOperationException from ResolveLlamaCppModel when the user passed an absolute or rooted path to a .gguf via --translate-model but that file does not exist. This branch only fires for path-shaped input (IsPathRooted or contains a separator); bare names go to the curated-models lookup.","triggerScenarios":"Calling the runner with --translate-model:/foo/bar.gguf where /foo/bar.gguf does not exist on disk.","commonSituations":"Typo in the path; relative-looking path that resolved wrong; model moved/deleted after the command was constructed; wrong working directory.","solutions":["Verify the path with File.Exists in your shell before invoking the runner.","Use an absolute path; if relative, confirm the runner's current working directory.","If you just want a name match, drop the path separator and pass the bare model name instead."],"exampleFix":"// before\nif (!File.Exists(name))\n    throw new InvalidOperationException($\"Translate model file not found: {name}\");\n\n// after\nif (!File.Exists(name))\n    throw new InvalidOperationException($\"Translate model file not found: '{name}'. Resolved full path: '{Path.GetFullPath(name)}'.\");","handlingStrategy":"validation","validationCode":"if (Path.IsPathRooted(name) && !File.Exists(name))\n    throw new InvalidOperationException($\"Translate model not found: '{name}' (resolved: '{Path.GetFullPath(name)}').\");","typeGuard":"static bool IsExistingModelPath(string name) => Path.IsPathRooted(name) && File.Exists(name);","tryCatchPattern":"null","preventionTips":["Validate File.Exists on user-supplied model paths before invoking the runner.","Use absolute paths to avoid working-directory surprises.","Expand environment variables in user-supplied paths."],"tags":["translate","llama-cpp","file-not-found","cli"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}