# XeLaTeX compilation fail (« Undefined control sequence. l.27 \sys_if_engine_luatex:T ») with fontspec package

After an update of all my packages, the upgrading from my old MiKTeX 2.9 to the last version, and the refreshing of the file name database (FNDB), my tex file wouldn’t compile anymore. I identified the problem as coming from the fontspec package which worked perfectly fine right before updating everything. When running, the compilation stops first on the following lines:

Package: fontspec 2019/03/15 v2.7c Font selection for XeLaTeX and LuaLaTeX
! Undefined control sequence.
l.27 \sys_if_engine_luatex:T


If I force to run though, I get several other errors which appear in the log file below. No PDF file emerges from the process.

I tried to uninstall (and deleting all files left) then to reinstall my MiKTeX distribution several times with 64 bits and 32 bits versions in case I did it wrong but it did not change anything to my problem.

I also checked with other packages as the one linked to the LaTeX2ε and LaTeX3 as it seemed to be in this topic but installing, uninstalling and reinstalling the packages l3kernel and l3packages had no effect on the compilation. This temporary solution from 2013 had no effect neither.

Ater several tests, I also found out that other packages seemed to be affected by my issue: polyglossia (as it works partly upon the fontspec package), the manyfoot package and the perpage package. For the manyfoot and perpage packages, I am not sure if it is related to the fontspec package althought it also worked fine before any update. It seems to me that the core issue stands with the fontspec package.

Any idea of how I could fix that issue?

I am using MiKTeX 2.9.7050 (32bits) and Texmaker 5.0.3 on Windows 10. Here is a M(N)WE:

\documentclass[10pt,a4paper]{article}
\usepackage{fontspec}
\begin{document}
Hello world!
\end{document}


And here is the log file until the first error (I may not post the whole log file which looks like a spam to the forum):

\c__fp_Bigg_trailing_shift_int=\count110
L3 Module: l3box 2014/08/23 v5354 L3 Experimental boxes
\c_empty_box=\box27
\l_tmpa_box=\box28
\l_tmpb_box=\box29
\g_tmpa_box=\box30
\g_tmpb_box=\box31
L3 Module: l3coffins 2014/08/23 v5354 L3 Coffin code layer
\l__coffin_internal_box=\box32
\l__coffin_internal_dim=\dimen109
\l__coffin_offset_x_dim=\dimen110
\l__coffin_offset_y_dim=\dimen111
\l__coffin_x_dim=\dimen112
\l__coffin_y_dim=\dimen113
\l__coffin_x_prime_dim=\dimen114
\l__coffin_y_prime_dim=\dimen115
\c_empty_coffin=\box33
\l__coffin_aligned_coffin=\box34
\l__coffin_aligned_internal_coffin=\box35
\l_tmpa_coffin=\box36
\l_tmpb_coffin=\box37
\l__coffin_display_coffin=\box38
\l__coffin_display_coord_coffin=\box39
\l__coffin_display_pole_coffin=\box40
\l__coffin_display_offset_dim=\dimen116
\l__coffin_display_x_dim=\dimen117
\l__coffin_display_y_dim=\dimen118
L3 Module: l3color 2014/08/23 v5354 L3 Experimental color support
L3 Module: l3candidates 2014/11/23 v5466 L3 Experimental additions to l3kernel
\l__box_top_dim=\dimen119
\l__box_bottom_dim=\dimen120
\l__box_left_dim=\dimen121
\l__box_right_dim=\dimen122
\l__box_top_new_dim=\dimen123
\l__box_bottom_new_dim=\dimen124
\l__box_left_new_dim=\dimen125
\l__box_right_new_dim=\dimen126
\l__box_internal_box=\box41
\l__coffin_bounding_shift_dim=\dimen127
\l__coffin_left_corner_dim=\dimen128
\l__coffin_right_corner_dim=\dimen129
\l__coffin_bottom_corner_dim=\dimen130
\l__coffin_top_corner_dim=\dimen131
\l__coffin_scaled_total_height_dim=\dimen132
\l__coffin_scaled_width_dim=\dimen133
)
(C:\Users\Erizo\AppData\Roaming\MiKTeX\2.9\tex/latex/l3kernel\l3unicode-data.de
f
File: l3unicode-data.def 2014/11/23 v5465 L3 Unicode data
)
(C:\Users\Erizo\AppData\Roaming\MiKTeX\2.9\tex/latex/l3kernel\l3xdvipdfmx.def
File: l3xdvidpfmx.def 2014/11/23 v5466 L3 Experimental driver: xdvipdfmx
))
Package: xparse 2014/11/25 v5471 L3 Experimental document command parser
\l__xparse_current_arg_int=\count111
\l__xparse_m_args_int=\count112
\l__xparse_mandatory_args_int=\count113
\l__xparse_processor_int=\count114
\l__xparse_v_nesting_int=\count115
)
Package: fontspec 2019/03/15 v2.7c Font selection for XeLaTeX and LuaLaTeX

! Undefined control sequence.
l.27 \sys_if_engine_luatex:T

• Welcome to TeX.SX! It looks like your version of fontspec is quite recent (2019/03/15), but your l3kernel is very old (2014/11/23). You need to update l3kernel. – Phelype Oleinik Jul 20 '19 at 19:41
• Do you have an admin installation? Did you update as admin and as user? – Mensch Jul 20 '19 at 19:52
• @PhelypeOleinik I did try to update the l3kernel. I did uninstall then reinstall it from the MiKTeX console as an admin. The console indicates, indeed, that the package was "packaged on 12-12_2014". So I uninstalled them then used the tds.zip files from CTAN to install them semi-manually but it didn't change anything. Would the tds.zip be outdated? Do you think I should try to install the two packages by running latex on every dtx file? There are like 40 or 60 and the documentation is not really extensive on where to place them in my MiKTeX location tree. – Mosley Jul 21 '19 at 8:50
• @Mensch I do have an admin installation and I did update everything as an admin. It does not seem possible to update my packages as a common user after updating as an admin? – Mosley Jul 21 '19 at 8:50
• It is, first open MiKTeX Console, choose use as admin, update. Then change to your user account, open MiKTeX Console, choose use as user and update ... Do that always you have to update MiKTeX ... – Mensch Jul 21 '19 at 11:55

At last it seems to me that you updated an very old version of MiKTeX which is already mentioned on the homepage of MiKTeX to can result in errors.

In your case it seems your MiKTeX system is corrupted and I would recommend to deinstall it completly (and TeXmaker too), then download the current complete installer from the homepage and install new. Why do you use a 32bit software (MiKTeX) on a 64bit system? Better use the 64bit version of MiKTeX: Go to https://miktex.org/download, click on all downloads and choose the net installer 64bit. After installing MiKTeX install the current TeXMaker too (then it should recognise the new MiKTeX and be able to call and use it).

With the following mwe (please see added command \listfiles to get a list of all used packages and version numbers in the log file)

% xelatex
\listfiles
\documentclass[10pt,a4paper]{article}

\usepackage{fontspec}

\begin{document}
Hello world!
\end{document}


I can compile with my current MIkTeX XeTeX, Version 3.14159265-2.6-0.999991 (MiKTeX 2.9.7050 64-bit) (preloaded format=xelatex 2019.2.5) without any errors or warnings an get the following list of used packages:

 *File List*
article.cls    2014/09/29 v1.4h Standard LaTeX document class
size10.clo    2018/09/03 v1.4i Standard LaTeX file (size option)
fontspec.sty    2019/03/15 v2.7c Font selection for XeLaTeX and LuaLaTeX
xparse.sty    2019-05-28 L3 Experimental document command parser
expl3.sty    2019-07-01 L3 programming layer (loader)
expl3-code.tex    2019-07-01 L3 programming layer
l3backend-xdvipdfmx.def    2019-04-06 v L3 Experimental backend support: xdvipdfmx
fontspec-xetex.sty    2019/03/15 v2.7c Font selection for XeLaTeX and LuaLaTeX
fontenc.sty
tuenc.def    2018/08/11 v2.0j Standard LaTeX file
fontspec.cfg
***********


As you can see your used version for expl3.sty is simply too old.

I guess you did some changings on your MiKTEX system as admin, some as user and this causes your culprit.

• I did a complete clean installation of MiKTeX (64bits) then a new installation of Texmaker (64bits) but I still had difficulties. Then I made a new clean installation of Texmaker after I tracked down all left files related to the program. I assume you were totally right by talking about corrupted distribution as part of the problem. The problem was fully resolved when the new Texmaker made a real clean config when it couldn't find any old config file. The file list is now up to date and the compilation runs smoothly. – Mosley Jul 21 '19 at 17:49