Skip to content

Msys2 detect / ofMenu / vs - #8657

Merged
danoli3 merged 4 commits into
openframeworks:masterfrom
danoli3:msys2-detect
Nov 8, 2026
Merged

danoli3 merged 4 commits into
openframeworks:masterfrom
danoli3:msys2-detect

Conversation

@danoli3

@danoli3 danoli3 commented Nov 8, 2026 •

Copy link
Copy Markdown
Member

Fixes: #8640

MSYS2 terminal:

Screenshot 2026-11-08 at 4 39 27 pm

of.sh: detect MSYS2 shells as msys2, pick the MSYS2 env in the menu

Fixes #8640

Problem

When of.sh runs from an MSYS2 UCRT64 / CLANG64 / CLANGARM64 shell, ofMenu reports vs / 64, and setup downloads the Visual Studio libs instead of the msys2 ones.

Changes (scripts/of.sh only)

Detection

Shell Before After
Git Bash (/git-bash.exe present, MSYSTEM=MINGW64) on x64 vs / 64 vs / 64 (unchanged)
Git Bash on Windows on ARM vs / 64 vs / arm64
MSYS2 UCRT64 vs / 64 msys2 / ucrt64
MSYS2 CLANG64 vs / 64 msys2 / clang64
MSYS2 CLANGARM64 vs / arm64 msys2 / clangarm64
MSYS2 MINGW64 vs / 64 msys2 / mingw64
MSYS2 plain MSYS shell vs / 64 msys2 / clangarm64 on ARM64, msys2 / ucrt64 on x64
  • Git Bash is identified by git-bash.exe / git-cmd.exe at its root, as suggested in the issue. MSYSTEM alone can't separate the two, because Git Bash also sets MSYSTEM=MINGW64.
  • An MSYS2 shell is detected by pacman, or by MSYSTEM being ucrt64|clang64|clangarm64|mingw64.
  • The plain MSYS shell falls back based on the CPU.

Native ARM64 detection

  • On Windows on ARM, both Git Bash and MSYS2's own bash run as emulated x64 and report PROCESSOR_ARCHITECTURE=AMD64 / uname -m x86_64. That's why ARM64 machines showed vs / 64.
  • hostIsArm64 now reads the native CPU from the registry first (HKLM\…\Session Manager\Environment\PROCESSOR_ARCHITECTURE, which is not emulated). It then falls back to MSYSTEM, PROCESSOR_ARCHITEW6432 and uname.
  • detectHostVsArch and the msys2 environment default both use it. On ARM64 the vs libs default becomes arm64, which makes download_libs pull x64 + arm64 + arm64ec.

Menu: choosing msys2 libraries now asks for the environment

MSYS2 environment?
  ucrt64      — GCC, UCRT (x64)  (detected)
  clangarm64  — Clang, UCRT (ARM64)
  clang64     — Clang, UCRT (x64)
  • Inside MSYS2, the detected environment is listed first as the default.
  • From Git Bash, the CPU default (clangarm64 / ucrt64) is listed first, marked (default).
  • mingw64 is listed only when it's the detected environment.

Downloads

  • The chosen or detected environment is passed to download_libs as -a <env>. That way, picking msys2 from Git Bash no longer falls back to Git Bash's MSYSTEM=MINGW64.
  • The value is exported only for that one download, so it can't leak into a later vs download in the same menu session.
  • A LIB_ARCH the user sets explicitly (LIB_ARCH=clang64 of update libs msys2) is still respected.
  • The help text lists LIB_ARCH=ucrt64|clang64|clangarm64|mingw64 for msys2.

MSYS2 without git

  • MSYS2 doesn't ship git, so the menu showed a git checkout as nightly package (no .git) and offered clone().
  • When git isn't on PATH, of.sh now uses Git for Windows' git.exe (Program Files or the per-user install). MSYS2 converts the /c/… path arguments for it.
  • With no git at all, a folder with .git shows git checkout (git not found — pacman -S git). clone() is offered only when there's no .git at all.

Menu

  • vsconfig() is shown only for the vs platform, not in MSYS2 shells. of vsconfig still works from any Windows shell.
  • OF menu version bumped to 0.4.6.

Windows ARM64

Screenshot 2026-11-08 at 4 44 46 pm

  • Host Windows ARM64 even when run in git bash (x64) will correctly identify host platform as arm64.

Fixes openframeworks#8640. Running of.sh from an MSYS2 UCRT64 / CLANG64 / CLANGARM64
shell was detected as "vs / 64" and setup downloaded the Visual Studio libs.

- Git for Windows has git-bash.exe at its root, MSYS2 doesn't. Git Bash
  (which also sets MSYSTEM=MINGW64) stays vs; an MSYS2 shell (pacman, or
  MSYSTEM ucrt64|clang64|clangarm64|mingw64) is now msys2 with OF_ARCH set
  to that environment. The plain MSYS shell falls back by CPU: clangarm64
  on ARM64 (read from the registry, since MSYS2's own bash is emulated x64
  there), ucrt64 on x64.
- Choosing msys2 in the libs menu now asks for the MSYS2 environment:
  the detected one first (default), then clangarm64, ucrt64, clang64.
- runLibsDownload passes the msys2 env to download_libs as -a, so the
  package matches the chosen env even from Git Bash, scoped to that
  download so it doesn't leak into a later vs download in the same session.
Git Bash (and MSYS2's own bash) run as emulated x64 on Windows on ARM and
report PROCESSOR_ARCHITECTURE=AMD64 / uname -m x86_64, so ofMenu showed
"vs / 64" on ARM64 machines. hostIsArm64 now reads the native CPU from the
registry first (not emulated), then MSYSTEM / PROCESSOR_ARCHITEW6432 /
uname; detectHostVsArch and the msys2 env default both use it. On ARM64 the
vs libs default becomes arm64 (download_libs pulls x64 + arm64 + arm64ec).
MSYS2 doesn't ship git, so ofHasGit failed and the menu showed a git
checkout as "nightly package (no .git)" and offered clone. When git isn't
on PATH, fall back to Git for Windows' git.exe (Program Files or the
per-user install). Without any git, a folder with .git is reported as
"git checkout (git not found — pacman -S git)" and clone is only offered
when there is no .git at all.

The vsconfig() menu entry is now shown for the vs platform only, not in
MSYS2 shells (`of vsconfig` still works from any Windows shell).
@danoli3

danoli3 commented Nov 8, 2026

Copy link
Copy Markdown
Member Author

Qwen Testing (Windows 11 ARM64, Git for Windows + MSYS2)

  • From MSYS2 UCRT64 with no git on PATH: of.sh version shows git msys2-detect @ <sha> through Git for Windows. With no git reachable (simulated), it shows git checkout (git not found — pacman -S git) and clone() is hidden.

  • Ran of.sh help → platform from Git Bash and from MSYS2 with MSYSTEM set to MSYS, UCRT64, CLANG64, CLANGARM64 and MINGW64. Results match the table above.

  • Simulated an x64 host (no registry entry, AMD64, x86_64): detectHostVsArch → 64.

  • Tested the MSYS2 environment picker with a stubbed menuPick from Git Bash and from UCRT64, CLANG64 and MINGW64. In each case the detected or default environment is first and is the one used.

  • Ran runLibsDownload with a stubbed download:

    • the picked environment reaches the msys2 download;
    • a following vs download sees no LIB_ARCH;
    • an explicit LIB_ARCH=clang64 is kept;
    • a stale LIB_ARCH=64 is ignored for msys2.

@danoli3 danoli3 added this to the 0.12.2 milestone Nov 8, 2026
@danoli3

danoli3 commented Nov 8, 2026

Copy link
Copy Markdown
Member Author

Screenshot 2026-11-08 at 4 52 26 pm

Msys2 now has 3 types downloads

@danoli3
danoli3 merged commit c857451 into openframeworks:master Nov 8, 2026
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MSYS2] not detected in ofMenu

1 participant