How to Fix “tlmgr Cannot Set Up TLPDB” on Ubuntu
At a glance
- 1. Identify the installation
Check which tlmgr runs and whether TeX Live came from Ubuntu packages or the upstream installer.
- 2. Use the matching manager
For Ubuntu-managed TeX Live, install and update packages with apt, not tlmgr.
- 3. Check the repository
For an upstream TeX Live installation, configure a reachable repository that matches its release.
- 4. Retry and verify
Run tlmgr again, then confirm the package or command is available.
The message “tlmgr: cannot setup TLPDB” means that tlmgr could not read or initialize the TeX Live package database. On Ubuntu, a common cause is using tlmgr with the TeX Live installation provided by Ubuntu’s package manager. That installation is meant to be managed with apt, not updated package-by-package with tlmgr.
First identify which TeX Live installation your commands are using. The fix depends on whether it came from Ubuntu packages or from the upstream TeX Live installer.
1. Identify your TeX Live installation
In a terminal, run:
which tlmgr
which pdflatex
tlmgr --version
The paths help distinguish installations. Ubuntu-packaged files commonly live under /usr/bin and /usr/share/texlive. An upstream installation commonly uses a versioned directory such as /usr/local/texlive/2024 (the year varies).
You can also ask TeX which root directory it is using:
kpsewhich -var-value=TEXMFROOT
If you have more than one TeX Live installation, the first matching command on your PATH may not belong to the installation you intended. Check the paths before changing anything.
2. If Ubuntu installed TeX Live, use apt
If the TeX Live files came from Ubuntu packages, install and update them through apt. For example:
sudo apt update
sudo apt install texlive-latex-extra
The package name depends on what you need. texlive-latex-extra provides many commonly used LaTeX packages; other collections and individual packages are available in Ubuntu’s repositories. To upgrade installed packages, use:
sudo apt upgrade
Do not try to make tlmgr update Ubuntu’s system TeX Live installation. Ubuntu divides TeX Live into distribution packages and applies updates through its own package repository. Mixing tlmgr changes with apt can also create inconsistent files or make later package upgrades confusing.
If you specifically need a newer TeX Live release than Ubuntu provides, install the upstream TeX Live distribution separately and make sure its bin directory comes first on your PATH. Avoid overwriting Ubuntu’s system-managed files.
3. If you installed TeX Live upstream, check its repository
For an upstream installation, tlmgr needs to read a package database, called the TLPDB, from a repository. Check the configured repository with:
tlmgr option repository
If the repository is missing or unreachable, set it to a CTAN mirror:
sudo tlmgr option repository https://mirror.ctan.org/systems/texlive/tlnet
Then try updating the manager and installed packages:
sudo tlmgr update --self --all
Use sudo only for a system-wide upstream installation. A user-mode installation has different permissions and should not be run as root.
The current tlnet repository is intended for the current TeX Live release. If your installation is from an older yearly release, its package database may no longer match the current repository. Point tlmgr to the archived repository for that same release, or install a supported current release. Do not switch an older installation to the current repository and assume it is a safe in-place upgrade.
4. Check connectivity and the database path
If the repository is appropriate but the error remains, check that the machine can access it and that the installation’s TeX Live directories are readable. A proxy, firewall, DNS problem, or an invalid repository address can prevent tlmgr from fetching the database. Retry after correcting the network or repository setting.
Also check that you are invoking the intended tlmgr. For example, if which tlmgr shows /usr/bin/tlmgr but your upstream installation is under /usr/local/texlive, you may be running Ubuntu’s copy rather than the upstream one. Invoke the tlmgr inside the upstream installation’s bin directory, or adjust PATH so its bin directory is found first.
Common mistakes
- Using
tlmgrto update Ubuntu’s TeX Live packages: useapt updateandapt upgradeinstead. - Using a repository for a different TeX Live year: select the matching archived repository or install the current release separately.
- Assuming there is only one installation: check
which tlmgr,which pdflatex, andTEXMFROOT; multiple installations can coexist. - Running every command with
sudo: root is appropriate for a system-wide installation, but not for a user-mode setup. - Reinstalling before checking the cause: first determine whether the problem is package-manager mismatch, repository configuration, or network access.
Once you have identified the installation, use its intended package manager: apt for Ubuntu’s TeX Live packages, or tlmgr for an upstream TeX Live installation with a compatible repository.
References
Spotted an error? Send a correction. Read how we write and check articles in our editorial policy.