Tx · LaTeX & TikZ

How to Fix “Can’t Find the Format File pdflatex.fmt”

Published By the 9to5Science editorial team

At a glance

  1. 1. Check the executable

    Find which pdflatex runs and confirm it belongs to the TeX installation you intend to use.

  2. 2. Look for the format

    Use kpsewhich to check whether that installation can locate pdflatex.fmt.

  3. 3. Regenerate the format

    Run fmtutil for the same TeX installation, using system or user scope as appropriate.

  4. 4. Retest the document

    Compile again and check that your editor is using the same pdflatex found in the terminal.

The error Can't find the format file pdflatex.fmt means that the pdflatex program being run cannot locate the precompiled format it needs to process LaTeX documents. The format may be missing, may not have been generated after installation, or may belong to a different TeX installation than the executable you are using.

On macOS, a common cause is having more than one TeX distribution installed—for example, MacPorts TeX Live and MacTeX—and having the terminal or editor select a different one than expected. Check the executable and format paths before reinstalling anything.

1. Check which pdflatex is running

In Terminal, run:

which -a pdflatex
pdflatex --version

which -a lists matching executables found on your PATH. If you see multiple paths, such as one under /opt/local (often used by MacPorts) and another under /Library/TeX, you have multiple TeX installations. The first matching executable is usually the one a terminal command uses.

Also check whether TeX can find the format:

kpsewhich pdflatex.fmt

If this prints a path, that is the format file TeX finds. If it prints nothing, the selected installation cannot locate the format through its current search paths. To inspect which kpsewhich is running, use which -a kpsewhich; it should come from the same TeX distribution as pdflatex.

2. Regenerate the format

TeX Live uses fmtutil to create and manage format files. For a system-wide TeX Live installation, try:

sudo fmtutil-sys --byfmt pdflatex

For a user-level TeX Live installation, try:

fmtutil --byfmt pdflatex

Use the command belonging to the same installation as the pdflatex reported above. The system-wide command may require an administrator password; the user-level command does not. On a MacPorts installation, for example, check that fmtutil-sys and pdflatex are both being resolved from the MacPorts installation. If the command is not found or resolves to another distribution, use the matching executable from that installation rather than mixing commands.

If the format still is not created, inspect the command’s output for a missing package, configuration error, or permission problem. You can also rebuild all formats for that installation with fmtutil-sys --all or, for a user-level installation, fmtutil --all. Rebuilding every format takes longer; it is usually not the first step to try.

3. Check for conflicting TeX installations

When several distributions are installed, a common failure pattern is that pdflatex comes from one distribution while fmtutil or the format file comes from another. Compare the paths from these commands:

which -a pdflatex
which -a fmtutil
which -a fmtutil-sys
kpsewhich pdflatex.fmt

If you intend to use MacPorts, make sure the MacPorts binaries are selected consistently. MacPorts commonly installs software under /opt/local, but your actual paths depend on your installation and shell configuration. If you intend to use MacTeX, select its TeX binaries consistently instead. Avoid copying a .fmt file from one distribution into another: formats depend on the TeX installation and configuration that created them.

4. Check your editor’s TeX path

A terminal and a TeX editor can use different executables. If the error occurs only in TeXShop or another editor, check its command or distribution settings and compare them with the terminal’s which -a pdflatex output. Set the editor to use the intended TeX distribution, then compile again. Restarting the editor can help if its environment was set before you changed your shell’s PATH.

Common mistakes

  • Running fmtutil from a different installation. Regenerating the format does not help if the editor keeps running another pdflatex.
  • Using sudo without checking the path. The administrator environment may have a different PATH, so sudo can run a different TeX Live command. Check the executable path and use the matching installation.
  • Deleting format files by hand. First regenerate the format and inspect the error output; manual deletion can create more missing-file problems.
  • Reinstalling everything immediately. Check executable and format paths first. A path mismatch is often the issue, and a full reinstall may leave the conflicting installations in place.

When kpsewhich pdflatex.fmt returns a path from the intended TeX installation and the editor runs that installation’s pdflatex, the format-file error should be resolved. If it persists, use the detailed output from fmtutil to identify a failed format build or an incomplete TeX Live installation.

References

  1. TeX Live documentation
  2. MacPorts Guide

Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.