{"record":{"id":"bafcefa825a7f2aa","repo":"SubtitleEdit/subtitleedit","slug":"operation-is-not-supported-on-this-platform-bafcef","errorCode":null,"errorMessage":"Operation is not supported on this platform.","messagePattern":"Operation is not supported on this platform\\.","errorType":"exception","errorClass":"PlatformNotSupportedException","httpStatus":null,"severity":"error","filePath":"src/ui/Logic/Download/TesseractDownloadService.cs","lineNumber":37,"sourceCode":"    private const string WindowsUrl = \"https://github.com/SubtitleEdit/support-files/releases/download/tesseract550/Tesseract550.zip\";\n    private readonly IZipUnpacker _zipUnpacker;\n\n    public TesseractDownloadService(HttpClient httpClient, IZipUnpacker zipUnpacker)\n    {\n        _httpClient = httpClient;\n        _zipUnpacker = zipUnpacker;\n    }\n\n    private static string GetTesseractUrl()\n    {\n        if (OperatingSystem.IsWindows())\n        {\n            return WindowsUrl;\n        }\n\n        // macOS/Linux use a package-manager install (\"brew install tesseract\" /\n        // \"apt install tesseract-ocr\") - see OcrViewModel.CheckAndDownloadTesseract.\n        throw new PlatformNotSupportedException();\n    }\n\n    public async Task DownloadTesseract(Stream stream, IProgress<float>? progress, CancellationToken cancellationToken)\n    {\n        await DownloadHelper.DownloadFileAsync(_httpClient, GetTesseractUrl(), stream, progress, cancellationToken);\n    }\n\n    public async Task DownloadTesseractModel(string modelUrl, Stream stream, IProgress<float>? progress, CancellationToken cancellationToken)\n    {\n        await DownloadHelper.DownloadFileAsync(_httpClient, modelUrl, stream, progress, cancellationToken);\n    }\n}","sourceCodeStart":19,"sourceCodeEnd":49,"githubUrl":"https://github.com/SubtitleEdit/subtitleedit/blob/17a9f0748781032255db3526b7215d2fb891e3af/src/ui/Logic/Download/TesseractDownloadService.cs#L19-L49","documentation":"PlatformNotSupportedException from TesseractDownloadService.GetTesseractUrl: only Windows downloads the Tesseract binary directly. macOS and Linux are expected to install Tesseract via their package manager (brew/apt), so the URL lookup intentionally throws to route the user to the package-manager path handled in OcrViewModel.CheckAndDownloadTesseract.","triggerScenarios":"GetTesseractUrl called on a non-Windows OS. The throw is by design - the comment documents that macOS/Linux use package-manager install instead.","commonSituations":"Calling DownloadTesseract on Mac/Linux when the user hasn't installed Tesseract via brew/apt yet. This is the expected control-flow signal that the package-manager path must be taken, not necessarily a bug.","solutions":["On macOS run: brew install tesseract","On Linux run: sudo apt install tesseract-ocr (or the distro equivalent).","On Windows, ensure the call path is correct so GetTesseractUrl returns WindowsUrl.","In caller code (OcrViewModel.CheckAndDownloadTesseract), catch PlatformNotSupportedException and guide the user to the package-manager instructions."],"exampleFix":"// before\nthrow new PlatformNotSupportedException();\n\n// after - name the path the user should take\nthrow new PlatformNotSupportedException(\n    OperatingSystem.IsMacOS()\n        ? \"Install Tesseract via 'brew install tesseract'.\"\n        : \"Install Tesseract via your package manager, e.g. 'apt install tesseract-ocr'.\");","handlingStrategy":"validation","validationCode":"if (!OperatingSystem.IsWindows())\n{\n    // do NOT call DownloadTesseract; instruct the user to install via package manager\n    var hint = OperatingSystem.IsMacOS() ? \"brew install tesseract\" : \"apt install tesseract-ocr\";\n    throw new InvalidOperationException($\"Install Tesseract manually: {hint}\");\n}","typeGuard":null,"tryCatchPattern":"try { await service.DownloadTesseract(stream, progress, ct); }\ncatch (PlatformNotSupportedException)\n{\n    // route user to OcrViewModel.CheckAndDownloadTesseract package-manager guidance\n}","preventionTips":["Skip DownloadTesseract entirely on Mac/Linux and show the package-manager hint.","Verify Tesseract is installed (which tesseract) before invoking OCR features.","Document the platform-specific install path in user help."],"tags":["platform","platformnotsupported","tesseract","package-manager","csharp"],"backgroundTag":null,"analyzedSha":"17a9f0748781032255db3526b7215d2fb891e3af","analyzedAt":"2026-08-13T18:11:43.374Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}