Fontspec \setmainfont and fontspec prevents compiling after MiKTeX packages update

fontspecmiktexmiktex-update

I updated every package with MiKTeX console today (Dec. 7, 2021), and now I have issues compiling with XeLaTeX any document that uses \setmainfont or \fontspec, but loading the fontspec package works fine. Sometimes they work, but usually not, and I have not been able to determine under which condition they work. Deleting the auxilary files doesn't change anything; I thought I could produce a pdf when not using synctex as a command option but it seems not to always work either. I tried reinstalling fontspec already. Trying to compile the .tex file, it leaves me with a either empty or incomplete .log file, and a .synctex(busy) file. It tends to crash after reaching fontspec.cfg.

Here's is a MWE of what is causing me issues:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Latin Modern Roman}

\begin{document}
Hello World!

\fontspec{Consolas}
Try this thing?

\IfFontExistsTF{Latin Modern Roman}{T}{F}

\IfFontExistsTF{Times New Roman}{T}{F}

\IfFontExistsTF{Consolas}{T}{F}

\end{document}

At some point it worked when commenting out \setmainfont but now it doesn't unless also commenting out \fontspec. The pdf produced still contains "T" for the three \IfFontExistsTF.

Sorry if there are details missing but I really don't know what more to look for and that is the best I could troobleshoot it. I could send a list of the packages that were updated if that could be helpful.

Best Answer

This is a due to bug in the miktex xetex binary. It has been reported here

https://github.com/MiKTeX/miktex/issues/984

As a work-around use lualatex.