Skip to content

feat(engines): discover MSYS2 tools as a fallback - #1233

Open
Stamina9 wants to merge 1 commit into
KnifeLemon:mainfrom
Stamina9:codex/msys2-engine-discovery
Open

Stamina9 wants to merge 1 commit into
KnifeLemon:mainfrom
Stamina9:codex/msys2-engine-discovery

Conversation

@Stamina9

@Stamina9 Stamina9 commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

What does this change?

Find FFmpeg, Tesseract and whisper-cli in native MSYS2 environments under msys64 on the Windows system drive, even when their bin folders are absent from PATH. These locations are searched after PATH and the usual installer folders; the user-selected and Filee-managed copies retain priority. FFmpeg still requires both ffmpeg and ffprobe in the same folder.

Addresses #1216. This covers automatic discovery in the standard location; custom MSYS2 roots still need PATH or a manually selected program. It does not change where Filee installs Tesseract language data.

Type of change

  • New feature or improvement
  • Documentation

How was it tested?

  • dotnet format Filee.slnx --verify-no-changes --no-restore
  • PortableEngineTests and EngineProbeTests: 35 passed on Windows. Generated directory trees cover FFmpeg in mingw64, Tesseract in clang64, whisper-cli in ucrt64, missing ffprobe and excluded MSYS Unix tools.
  • Tested with an actual MSYS2 installation: tests use temporary files, not executable programs.
  • Full solution test: Engines 2343 passed (263 skipped); Core had two WebDownloader failures with HTTP 502; Platform 99, CLI 84 and Setup 230 passed. App suite still running.

Checklist

  • No new UI strings
  • No new third-party code or binaries
  • The PR does one thing

Look for FFmpeg, Tesseract and whisper-cli in the native MSYS2
environments on the system drive after the existing system locations.

Addresses KnifeLemon#1216.
@Stamina9
Stamina9 requested a review from KnifeLemon as a code owner November 6, 2026 14:29
@github-actions github-actions Bot added the feature New features label Nov 6, 2026

@KnifeLemon KnifeLemon left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for picking this up, @Stamina9! The order is exactly what we agreed on #1216: the user's copy, then Filee's, then PATH and the installer folders, and MSYS2 last. Skipping usr/bin is right too, and so is leaving tessdata alone: Filee passes its own language data, so even a MINGW64 Tesseract without tessdata works.

Must fix

1. C:\msys64 can't be trusted by its name

Windows lets any signed-in account create folders in the root of C:. So on a PC shared by several accounts, someone else can create C:\msys64\ucrt64\bin\tesseract.exe without any admin rights. Filee would then start that program as whoever runs Filee, without a click, because a found copy gets a version check on every launch (EngineDownloadService.StatusOf → CopyVersions.Installed). The other places we search on Windows can only be changed by an admin or by the user themselves, so this would be the first one that another account can write to.

Could you take the folder from MSYS2's own installer record instead?

  • The installer writes an entry under HKCU (or HKLM for an all-users install): Software\Microsoft\Windows\CurrentVersion\Uninstall\{guid}, with DisplayName and InstallLocation.
  • Another account can't change those.
  • It also finds D:\msys64, so the "custom root" gap in your description goes away.
  • A copy unpacked by hand keeps using PATH or Use my copy, which is fine.

I read this from the installer's source and haven't seen it on a real install, so please check the values on one.

2. The tests don't reach the search

They call Msys2Folders and FolderWithPrograms directly. I removed the two lines in SystemFolders and reversed the environment list, and all three cases still passed. Please split the part that goes from the registry entries to the folder list into a small function that takes them as input, and test the result and its order.

Worth doing while you're here

  • ARM64: clangarm64 comes after the x64 environments, so an ARM PC with both gets the emulated tool over the native one. On an x64 PC it can't run at all. Please put it first on ARM64 and leave it out on x64 (RuntimeInformation.OSArchitecture).
  • Whisper: MSYS2's whisper.cpp package doesn't appear to include a model, so the card can say "Found on this PC" while Whisper stays unavailable until a model is there. One sentence in docs/ENGINES.md would cover it.

@yzc3582, once this is updated, could you try it with Use my copy cleared and MSYS2 not on PATH? You have the setup we don't, with FFmpeg and whisper.cpp in MINGW64 and Tesseract in CLANG64.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New features

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants