SubtitleEdit/subtitleedit · error · PlatformNotSupportedException

Operation is not supported on this platform.

Error message

Operation is not supported on this platform.

What it means

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.

Source

Thrown at src/ui/Logic/Download/TesseractDownloadService.cs:37

    private const string WindowsUrl = "https://github.com/SubtitleEdit/support-files/releases/download/tesseract550/Tesseract550.zip";
    private readonly IZipUnpacker _zipUnpacker;

    public TesseractDownloadService(HttpClient httpClient, IZipUnpacker zipUnpacker)
    {
        _httpClient = httpClient;
        _zipUnpacker = zipUnpacker;
    }

    private static string GetTesseractUrl()
    {
        if (OperatingSystem.IsWindows())
        {
            return WindowsUrl;
        }

        // macOS/Linux use a package-manager install ("brew install tesseract" /
        // "apt install tesseract-ocr") - see OcrViewModel.CheckAndDownloadTesseract.
        throw new PlatformNotSupportedException();
    }

    public async Task DownloadTesseract(Stream stream, IProgress<float>? progress, CancellationToken cancellationToken)
    {
        await DownloadHelper.DownloadFileAsync(_httpClient, GetTesseractUrl(), stream, progress, cancellationToken);
    }

    public async Task DownloadTesseractModel(string modelUrl, Stream stream, IProgress<float>? progress, CancellationToken cancellationToken)
    {
        await DownloadHelper.DownloadFileAsync(_httpClient, modelUrl, stream, progress, cancellationToken);
    }
}

View on GitHub (pinned to 17a9f07487)

Solutions

  1. On macOS run: brew install tesseract
  2. On Linux run: sudo apt install tesseract-ocr (or the distro equivalent).
  3. On Windows, ensure the call path is correct so GetTesseractUrl returns WindowsUrl.
  4. In caller code (OcrViewModel.CheckAndDownloadTesseract), catch PlatformNotSupportedException and guide the user to the package-manager instructions.

Example fix

// before
throw new PlatformNotSupportedException();

// after - name the path the user should take
throw new PlatformNotSupportedException(
    OperatingSystem.IsMacOS()
        ? "Install Tesseract via 'brew install tesseract'."
        : "Install Tesseract via your package manager, e.g. 'apt install tesseract-ocr'.");
Defensive patterns

Strategy: validation

Validate before calling

if (!OperatingSystem.IsWindows())
{
    // do NOT call DownloadTesseract; instruct the user to install via package manager
    var hint = OperatingSystem.IsMacOS() ? "brew install tesseract" : "apt install tesseract-ocr";
    throw new InvalidOperationException($"Install Tesseract manually: {hint}");
}

Try / catch

try { await service.DownloadTesseract(stream, progress, ct); }
catch (PlatformNotSupportedException)
{
    // route user to OcrViewModel.CheckAndDownloadTesseract package-manager guidance
}

Prevention

When it happens

Trigger: GetTesseractUrl called on a non-Windows OS. The throw is by design - the comment documents that macOS/Linux use package-manager install instead.

Common situations: 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.

Related errors


AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13). Data as JSON: /api/errors/bafcefa825a7f2aa. Report an issue: GitHub.