# MiKTeX graphics version 1.3b bug on Windows 10 (\set@curr@file undefined)

After updating MiKTeX graphics package on 10/5/19 to version 1.3b (packaged on 10/4/2019 8:11:27 PM), I am unable to compile LaTex files that contain \includegraphics{}.

My system: Windows 10 with MiKTeX 2.9.7200

A minimum working example:

\documentclass{article}
\usepackage{graphics}

\begin{document}

\begin{figure}
\includegraphics{MC_Antenna_Gain}
\end{figure}

\end{document}


The error report

This is pdfTeX, Version 3.14159265-2.6-1.40.20 (MiKTeX 2.9.7200)
entering extended mode
(C:/Users/nicrog/Dropbox/T_P_2/Scholar/Grants/Written/EWU_20/Test.tex
LaTeX2e <2018-12-01>
("C:\Program Files (x86)\MiKTeX 2.9\tex/latex/base\article.cls"
Document Class: article 2019/08/27 v1.4j Standard LaTeX document class
("C:\Program Files (x86)\MiKTeX 2.9\tex/latex/base\size10.clo"))
("C:\Program Files (x86)\MiKTeX 2.9\tex/latex/graphics\graphics.sty"
("C:\Program Files (x86)\MiKTeX 2.9\tex/latex/graphics\trig.sty")
("C:\Program Files (x86)\MiKTeX 2.9\tex/latex/graphics-cfg\graphics.cfg")
("C:\Program Files (x86)\MiKTeX 2.9\tex/latex/graphics-def\pdftex.def"))
No file Test.aux.
("C:\Program Files (x86)\MiKTeX 2.9\tex/context/base/mkii\supp-pdf.mkii"
) ("C:\Program Files (x86)\MiKTeX 2.9\tex/latex/oberdiek\epstopdf-base.sty"
("C:\Program Files (x86)\MiKTeX 2.9\tex/generic/oberdiek\infwarerr.sty")
("C:\Program Files (x86)\MiKTeX 2.9\tex/latex/oberdiek\grfext.sty"
("C:\Program Files (x86)\MiKTeX 2.9\tex/generic/oberdiek\kvdefinekeys.sty"
("C:\Program Files (x86)\MiKTeX 2.9\tex/generic/oberdiek\ltxcmds.sty")))
("C:\Program Files (x86)\MiKTeX 2.9\tex/latex/oberdiek\kvoptions.sty"
("C:\Program Files (x86)\MiKTeX 2.9\tex/latex/graphics\keyval.sty")
("C:\Program Files (x86)\MiKTeX 2.9\tex/generic/oberdiek\kvsetkeys.sty"
("C:\Program Files (x86)\MiKTeX 2.9\tex/generic/oberdiek\etexcmds.sty"
("C:\Program Files (x86)\MiKTeX 2.9\tex/generic/oberdiek\ifluatex.sty"))))
("C:\Program Files (x86)\MiKTeX 2.9\tex/generic/oberdiek\pdftexcmds.sty"
("C:\Program Files (x86)\MiKTeX 2.9\tex/generic/oberdiek\ifpdf.sty")))
! Undefined control sequence.
\Ginclude@graphics ...\Ginput@path \set@curr@file
{#1}\edef \uq@curr@file {\...
l.8    \includegraphics{MC_Antenna_Gain}

?


I will report this potential bug to https://github.com/MiKTeX/miktex-packaging/issues/ as well.

As noted in the question, this is an issue in the way MiKTeX has integrated the latest LaTeX kernel change. The graphics package has been updated but not the LaTeX kernel, and this leads to the error.

A temporary fix is to add the necessary definitions to your source file: luckily these are small

\documentclass{article}
\makeatletter
\def\set@curr@file#1{%
\begingroup
\escapechar\m@ne
\xdef\@curr@file{\expandafter\string\csname #1\endcsname}%
\endgroup
}
\def\quote@name#1{"\quote@@name#1\@gobble""}
\def\quote@@name#1"{#1\quote@@name}
\def\unquote@name#1{\quote@@name#1\@gobble"}
\makeatother
\usepackage{graphics}

\begin{document}

\begin{figure}
\includegraphics{example-image-a}
\end{figure}

\end{document}


Of course, hopefully the kernel will be updated shortly in MiKTeX.

• Updating my MiKTeX install, looks like the fix is already in MiKTeX. Oct 6, 2019 at 7:49
• I updated miktex but it didn't solve. this comment solves the issue until a new update comes from miktex.
– Ali
Oct 7, 2019 at 2:27
• @Ali Try updating the formats (Settings -> Formats -> Build format) both in user and admin mode. This resolved the problem for me. Oct 7, 2019 at 10:48
• Same problem using BasicTeX on macOS, the proposed temporary fix works. Does anyone know where BasicTeX issues can be reported (is it really just this form or via email)? Oct 9, 2019 at 9:29
• @maphy-psd Updating your TeX system should sort the issue; you may need to force a format-rebuild Oct 9, 2019 at 18:48

The core of this issue has been fixed (on 2019-10-06) in MikTeX, but since the situation involves formats and is overall a bit tricky I wrote up a guide at https://github.com/MiKTeX/miktex-packaging/issues/131 explaining (roughly) what is happening here and what you can do if you are still suffering from this issue. This is copied pretty much verbatim from over there.

OK, this turned out to be quite a tricky issue, since there are several things at play here.

# The heart of the issue: Incompatible packages

The core of the issue was as follows. The LaTeX development team released an update of the LaTeX kernel (LaTeX base in ltxbase) along with several core packages (e.g. graphics, graphicx, amsmath). The updated core packages are intended to work with the updated LaTeX kernel and some need the correct version to function properly. Among these core packages was graphics/graphicx.

The packages and the kernel were uploaded to CTAN at almost the same time and arrived in TeX live with the same sweep of updates. Due to unfortunate timing, only graphics was updated in MikTeX leaving the LaTeX kernel on an older version. Using the graphicx package with the older kernel causes the error messages described in https://github.com/MiKTeX/miktex-packaging/issues/132, https://github.com/MiKTeX/miktex-packaging/issues/133 and here (as well as linked questions and duplicates).

The core issue of the MikTeX package server distributing incompatible packages was fixed swiftly the next day on 2019-10-06 (UTC). Since then the server has distributed the newest LaTeX base package (2019-10-01) that matches graphics.

# The LaTeX kernel is special

Usually when a package is updated it is enough to renew the file name database to tell TeX about the addition or removal of files. This happens automatically when the MikTeX Console is used to update or install packages (same for TeX live's tlmgr and friends) so the average user will not have to worry about that.

But the LaTeX kernel is special. It defines a TeX format and is directly baked into the executable so that all LaTeX commands are available from the start without loading any packages (the LaTeX commands can be used without any \usepackage directly from the start). This means that it is not enough to renew the file name database when the kernel was updated: the formats also need to be regenerated and baked into the executables. Again this should happen automatically when the MikTeX Console is used to update the LaTeX kernel package.

# OK, so what can I do?

## Update in Admin and User mode

First of all you need to make sure that your MikTeX system is fully up to date. Run an update (see https://tex.stackexchange.com/a/55473/35864). If you have a multi-user MikTeX make sure to run the Update in User and Admin mode.

Double check that lxtbase is up to date by going to the Packages tab in the MikTeX Console and searching for ltxbase. The install date should be 2019-10-06 or later and the packaged date 2019-10-05. If you have a multi-user MikTeX install, the package may only be installed in one of the two modes. You do not have to click install in the other mode, you just have to make sure that it is up to date when it is installed.

In an ideal world that should be it. The formats should automatically be generated as needed during the update and things should work.

Small aside: The admin–user distinction is a common source of problems in MikTeX. The updater will always only update the packages installed with its permission level. If you have a multi-user installation and installed packages with User-level as well as Admin-level permissions, packages may get out of sync if you only update with one permission level. Whenever you encounter an update-related issue always make sure to update your system in Admin and User mode, often that makes issues go away. (Of course this only applies to multi-user MikTeX installs.)

You can check your LaTeX format by running a simple LaTeX document like

\documentclass{article}
\begin{document}
Lorem
\end{document}


Open the resulting .log file and check out the first few lines

This is pdfTeX, Version 3.14159265-2.6-1.40.20 (MiKTeX 2.9.7200 64-bit) (preloaded format=pdflatex 2019.10.12)  12 OCT 2019 11:42
entering extended mode
**./formatdate.tex
(formatdate.tex
LaTeX2e <2019-10-01>
("C:\Program Files\MiKTeX 2.9\tex/latex/base\article.cls"
Document Class: article 2019/08/27 v1.4j Standard LaTeX document class


The important bit is the

LaTeX2e <2019-10-01>


the date should be 2019-10-01 or above.

The date in the preloaded format=pdflatex 2019.10.12 in the very first line should show a date after 2019-10-06.

You can use the command

kpsewhich --engine=pdftex pdflatex.fmt


from the terminal to find out where your format resides. The folder may give you a hint whether or not you are dealing with a User- or Admin-controlled format. This is important for the next step. If it is C:/Users/<User>/AppData/Local/MiKTeX/2.9/miktex/data/le/pdftex/pdflatex.fmt the format is user-controlled, if the format resides in C:/ProgramData/MiKTeX/2.9/miktex/data/le/pdftex/pdflatex.fmt we're talking about an Admin-controlled format. If the file path looks nothing like the two examples it may well be that you have a spurious format spooking around somewhere.

## Recreate the formats

If your formats are not new enough, MikTeX either did not recreate the format during the update or it did recreate the formats, but still picks up older versions of the formats.

You can rebuild the TeX formats as described in MiKTeX: Error After Update: "Sorry, but pdflatex did not succeed.". You will need to rebuild all the formats you want to use (probably at least pdflatex, latex, xelatex, lualatex). It may be possible to simply select all formats and rebuild them, but some formats may produce errors on rebuild. In that case you may need to hand-pick the formats you need.

Again if you have a multi-user installation there might be a need to do this in Admin and User mode. Generally I recommend to rebuild the formats in Admin mode first (if you have Admin rights that is) and only then if still necessary in User mode.

In case the relevant formats create error you can not resolve or understand on rebuilding, ask a question on your favourite TeX forum and give enough details so people understand what you did.

If you rebuilt the formats and still MikTeX doesn't pick up the correct formats, your MikTeX might be misconfigured. This is then going to be a specific issue that can only be diagnosed with more detailed information about your system. Again it might be better to ask a question with as much detail as possible on your favourite TeX forum.

The fix from Joseph's answer is intended to be a temporary workaround. It should not be needed any more since the correct kernel version is now available in MikTeX. Please don't use this workaround any more. Instead make sure that you format gets updated correctly.

If you want to know more about TeX formats, LaTeX etc., have a look at http://www.tug.org/levels.html and What is the difference between TeX and LaTeX?. Overleaf has a nice article on formats at https://www.overleaf.com/learn/latex/Articles/The_two_modes_of_TeX_engines:_INI_mode_and_production_mode.

Incidentally new installers and the like will probably not help here, since this is purely an issue related to things that happen after installation. Indeed it may not even help to remove MikTeX and install a new version if problematic files remain in directories not controlled by MikTeX. It is therefore important to try and understand where the problem comes from before going on an uninstall-reinstall spree.

# MacTeX

As it turns out there is a related issue in MacTeX (which is based on TeX live and not on MikTeX): \includegraphics broken on MacTeX 2019?. Updates in MacTeX don't trigger format rebuilding, which means that even though all packages are up to date one might be stuck with an older LaTeX format. In that case

fmtutil-sys --all


should help fix the issue.

A more detailed discussion about why that is necessary is at https://tug.org/pipermail/tex-live/2019-October/044119.html.

Using use package graphicx (which call graphics) instead of graphics works fine with recent MikTeX (just upgraded):

\documentclass{article}
\usepackage[demo]{graphicx} % <--- in real document remove option "demo"

\begin{document}

\begin{figure}
\includegraphics{MC_Antenna_Gain}
\end{figure}

\end{document}


result:

• Thanks Zarko -- I had already tried that without the [demo] when I posted this. However, I can confirm that adding the [demo] does work, but the black box is not really useful in the end.
– uRog
Oct 6, 2019 at 15:07
• @uRog, option demo I use since I haven't your picture. In real document, you must remove this option (as I noted in code example) and your image should show up. Oct 6, 2019 at 16:00
• @Zarko This works for me if I use demo and get a black box. If I do not use demo it gives the same error message as the graphics package. I did replace your graphic MC_Antenna_Gain with one of my own. Oct 10, 2019 at 0:56
• These two steps from the above comments solved my issue: 1. "If you have a multi-user installation and installed packages with User-level as well as Admin-level permissions, packages may get out of sync if you only update with one permission level." 2. You will need to rebuild all the formats you want to use (probably at least pdflatex, latex, xelatex, lualatex)." Apply step 2 in BOTH user level and admin level. Oct 16, 2019 at 21:58
• Thanks @moewe. I posted a link to your answer in another page! Oct 16, 2019 at 22:15