This is another nerd post, but don’t worry, it’s short. I ran into a problem updating my TeXLive installation, and all the solutions I found on the internet were misleading. Note that what follows only applies if you installed your TeXLive from the install script, not via your distribution’s package manager. In the latter case, the error described below is the intended behavior. (But really, in order to get the full use out of TeXLive you shouldn’t be using the repo version, as those tend to be both old and static.)

If you try to update your TeXLive installation on Debian/Ubuntu, you may get an error message saying that it’s “running in user mode” and “can’t initialize TLPDB”. This may surprise you if you, like I, installed TeXLive not via the package manager but from the install script. The causes of this are two fold:

  • When you run sudo tlmgr by default it does not inherit your path, so if you’ve installed TexLive into /opt or /usr/local it will not be found. Normally this would just result in a “command not found” error except…

  • If you have also accidentally installed TeXLive through your package manager (e.g., as a dependency of something else), then the tlmgr that sudo will find will be that one. And Debian/Ubuntu TeXLive installations are built to never allow updates to be applied globally, only in user mode (and for good reason: the global set of TeXLive packages is the set that other packages depend on when they have TeXLive as a dependency).

The solution is to purge the package manager copy of TeXLive from your system:

sudo apt-get purge "texlive*"

To run tlmgr via sudo, you’ll either need to explicitly set your path in it:

sudo env "PATH=$PATH" tlmgr update --all

or else add the path to tlmgr to the secure_path setting in /etc/sudoers. The latter is probably more secure, as it only allows running of tlmgr and the associated TeXLive tools from sudo, not everything in your path. (If you want to get all fancy, you could add symlinks to the TeXLive binaries (latex, etc.) into the relevant locations, so that you could then force-install any repo packages that depended on TeXLive, without installing TeXLive.)

Some of the wrong suggestions I saw in my search included:

  • “Run tlmgr init-usertree to setup your user TeXLive directories”. This won’t work because you almost certainly already have your usertree setup, so it will simply do nothing.

  • Install xzdec. Apparently the repo copy depends on this, but it’s not listed as a dependency. But the non-repo TeXLive does not suffer from this.

  • “The behavior is as intended” – For repo-installed copies of TeXLive, yes. But not for the manually-installed version.