# Fontspec compilation error with MacTeX-2018

Fontspec (and several other packages) were not working. I reinstalled MacTeX-2018, but the same errors keep coming up (see below). l3kernel & l3packages are both installed. All packages on TeX Live Utility are up to date. I'm running macOS Mojave.

Input:

\documentclass{article}
\usepackage{fontspec}
\begin{document}
\section{Section}
\end{document}


Output:

TraditionalBuilder: Engine: xelatex. Invoking latexmk... done.

Errors:

/opt/local/share/texmf-texlive/tex/latex/l3packages/xparse/xparse.sty:26:
Missing = inserted for \ifnum. [\RequirePackage{expl3}[2018-04-12]]
/opt/local/share/texmf-texlive/tex/latex/l3packages/xparse/xparse.sty:27:
Missing = inserted for \ifnum. [\@ifpackagelater{expl3}{2018-04-12}]
/opt/local/share/texmf-texlive/tex/latex/fontspec/fontspec.sty:23:
Missing = inserted for \ifnum. [\ProvidesExplPackage]
/opt/local/share/texmf-texlive/tex/latex/fontspec/fontspec-xetex.sty:43:
Missing = inserted for \ifnum. [\ProvidesExplPackage]

Warnings:

/opt/local/share/texmf-texlive/tex/latex/fontspec/fontspec-xetex.sty:
Package fontspec Warning:
I have found the tuenc.def encoding definition file(fontspec)
but the TU encoding is not defined by the LaTeX2e(fontspec)
kernel; attempting to correct but you really should(fontspec)

• Apparently your PATH variable points to a MacPorts installed version of TeX Live. Remove it. – egreg Apr 20 '19 at 14:31
• Please tell us which version numbers of fontspec (2019/02/12 v2.7b?), fontspec-xetex (2019/02/12 v2.7b?), and tuenc.def (tuenc.def) are installed on your system. (The information in parentheses in the preceding sentence is the version information on my MacTeX2018 installation -- no MacPort, just the "straight" version.) – Mico Apr 20 '19 at 14:34
• @iteu What's the output of the terminal command kpsewhich --var-value=TEXINPUTS? – egreg Apr 20 '19 at 14:59
• @iteu You should remove the MacPorts TeX Live with MacPorts tools, otherwise you'll remain with TeX binaries in /opt/local/bin`. I abandoned MacPorts several years ago. – egreg Apr 20 '19 at 15:42