This is an adaptation of some notes I had taken combining cfr's and Silke's answers on How to install "vanilla" TeXLive on Debian or Ubuntu?. Much of it is taken verbatim from those answers, and other things I am not interested in are described there.
This answer explains how to install and maintain TeX Live using a dedicated user account, in order to avoid potential risks to the system directories and your home directory, and how to use a fake package to let the package manager know that the dependencies are statisfied and it need not pull TeX Live from the distro's repo.
1) Set up a dedicated user/group and create a suitable home for TeX Live
This method protects your system directories and your home. The tladmin
user cannot write to your normal home directory.
Notes:
- this, the setting of
PATH
and the installation of the fake package are the only parts you need root privileges for;
- in general, if you want to change anything under
/usr/local/texlive
, su - tladmin
before you do it. If you want to do something outside of users' home directories (e.g., in /etc
), you need root privileges (sudo or similar).
1.1) Create the user
Note: If you have previously installed TeX Live with the TUG installer, omit the -m
flag from the following command.
sudo useradd -d /usr/local/texlive -m -r -U -s /bin/sh tladmin
This creates a new user, tladmin
, as a member of a new group, also named tladmin
. It creates a home directory for tladmin
at /usr/local/texlive
.
If you have previously installed TeX Live from upstream, once you have created the new user, do this:
sudo chown -Rh tladmin:tladmin /usr/local/texlive
Set the password for the new user
sudo passwd tladmin
1.2) Hide the name of the new user from the login screen
Open /var/lib/AccountsService/users/tladmin
(create it if necessary)
sudo vim /var/lib/AccountsService/users/tladmin
if the file already exists, make sure there's the line
SystemAccount=true
under the [User]
section.
Otherwise, just write these two lines in it:
[User]
SystemAccount=true
2) Installation
Login as tladmin
:
su - tladmin
then download and run the installer:
wget http://mirror.ctan.org/systems/texlive/tlnet/install-tl-unx.tar.gz
tar xvfz install-tl-unx.tar.gz
rm -i install-tl-unx.tar.gz
cd install-tl-... *press TAB*
./install-tl
The command ./install-tl
starts the installation process. You can change all kind of options there. Most of the default settings are sane, but consider that not installing the doc and source trees will save you a lot of disk space (around 50%). This comes with the downside of having to look up documentation online, instead of locally.
If you want to reduce disk space further you can also change the installation scheme or collections, but this will result in not having certain packages installed by default. You can, however, install them later through the TeX Live manager.
The only thing I personally like to change is the location of TEXMFHOME, using in ~/.texmf
instead of the default ~/texmf
, to make it hidden.
When you're done setting up the options, press i
to start the installation. The full installation is likely to take a long time, about an hour even on a good connection.
After the installation has completed you can delete the directory with the installation files:
rm -rf /usr/local/texlive/install-tl- *hit TAB*
Interruptions
If for some reason the installation is interrupted it can probably be resumed by running the installer again. This will prompt you to continue the installation.
If you want to start the installation from the beginning it's probably wise to remove the following installed elements +/- possible elements mentioned in mcbetz's answer on How to remove everything related to TeX Live for fresh install on Ubuntu?.
rm -rf /usr/local/texlive/2019
Failures
Such a long installation process may fail due to interruptions in communications or other reasons.
In such a case, you may want to to restart the installation, but this time choose the smallest configuration that would get it going.
Then, you can install all missing components with tlmgr --gui
.
3) Set the PATH
Note: on [1-1] there are instructions on how to avoid having to adapt /etc/profile.d/texmf.sh
when you install a new edition of TeX Live, using a system of symbolic links.
Now you need to add TeX Live's executables directory to the PATH
so that the system can find them when you issue a command.
Login as your normal user (in order to be able to use sudo
)
su - <your user>
open or create the file /etc/profile.d/texlive.sh
sudo vim /etc/profile.d/texlive.sh
and write in it
# /etc/profile.d/texlive.sh
TeX_dir="/usr/local/texlive/2019"
if [[ $UID != 0 && -d $TeX_dir/bin/x86_64-linux ]]; then
case ":$PATH:" in
*":$TeX_dir/bin/x86_64-linux:"*) :;; # already there
*) PATH="${PATH:+$PATH:}$TeX_dir/bin/x86_64-linux";; # add it
esac
fi
unset TeX_dir
This avoids adding TeX Live binaries automatically to root's PATH, as would happen if you set it in /etc/environment
.
It also avoids adding TeX Live binaries' directory twice to the PATH
3-4. ("Files with the .sh extension in the /etc/profile.d
directory get executed whenever a Bash login shell is entered (e.g. when logging in from the console or over SSH), as well as by the Display Manager when the desktop session loads." 3-1. Apparently, they're also run when a non-login Bash is entered (add an echo
to the script and open a terminal to try out), which appends TeX Live's directory to the PATH
a second time.)
Log out, then log back in.
Notes:
- Fedora doesn't use the
MANPATH
environment variable to know where to look for man pages. In the end, man tlmgr
, for instance, works even without setting the MANPATH
. See also 3-5.
- I haven't been able to make standalone Info pick up TeX Live's manuals. Apparently Fedora doesn't use
INFOPATH
neither and I didn't find any documentation about what it actually uses. You can make Emacs find those manuals by adding (add-to-list 'Info-additional-directory-list (car (last (file-expand-wildcards "/usr/local/texlive/20*/texmf-dist/doc/info"))))
to your Emacs initialization file, but for standalone Info I'll just leave a link to an open question on Fedora's forums: How to change the INFOPATH, possibly only user wide?
4) Fake the packages
You'll need to install a dummy-package in order to satisfy dependencies involving TeX Live components that have been installed by the TUG installer. Otherwise installing software that require those components will pull down texlive-*
packages like crazy (see [4-3]).
Use the appropriate package among those listed on [4-1]. For TeX Live 2019 on Fedora 30 the one made for RHEL7 [4-2] does the job.
Unzip the archive and run
sudo dnf install /path/to/texlive-dummy[…].rpm
Then you should be able to install another package that depends on TeX without downloading tons of dependencies.
Other sources for dummy packages (which I’ve not tested) are
5) Test
Note: all of the following commands should work no matter which user runs them, except for tlmgr
which needs to be run as tladmin
.
If everything went well all TeX-related commands should work. Verify this by checking the output of
which tex
which should be
/usr/local/texlive/2019/bin/x86_64-linux/tex
Last time I installed TeX Live (v. 2019 on Fedora 30) which tex
was failing because the test in /etc/profile.d/texlive.sh
, [[ -d $TeX_dir/bin/x86_64-linux ]]
, returned false. Check the permissions of directories in /usr/local/
,
ls -l /usr/local/
it may be that texlive
has rwx------
(700
) permissions. If that's the case, run
sudo chmod 755 /usr/local/texlive/
to fix the issue.
Try some other commands
man tlmgr
info tlmgr
tlmgr --version
pdflatex --version
biber --version
Another issue I had last time I installed TeX Live was Biber rasing this error:
biber: error while loading shared libraries: libnsl.so.1: cannot open shared object file: No such file or directory
after installing libnsl
it complained again:
biber: error while loading shared libraries: libcrypt.so.1: cannot open shared object file: No such file or directory
You can find which packages provide the missing files with
dnf provides libnsl.so.1
dnf provides libcrypt.so.1
then install them:
sudo dnf install libnsl libxcrypt-compat
6) Make your classes, packages and input files available to TeX Live
If you have personal classes, packages or input files, put them in ~/<your setting for TEXMFHOME>/tex/latex/
(you may need to create it). A symlink will do if you want to keep them stored somewhere else.
Note: files in the local texmf tree can bee loaded with just \input{filename}
instead of \input{path/to/file}
.
7) getnonfreefonts
Some typefaces are not distributed with TeX Live's installer due to licensing issues. You have to use a separate script, getnonfreefonts
, to install them.
Note: don't run getnonfreefonts
with the --user
flag. It causes problems because it executes updmap
(see [7-2]).
su - tladmin
wget https://tug.org/fonts/getnonfreefonts/install-getnonfreefonts
texlua install-getnonfreefonts
rm -i install-getnonfreefonts
getnonfreefonts --sys -a
Check if all the fonts have been installed correctly
getnonfreefonts --sys -l
If they have not, run
getnonfreefonts --sys -a
again.
8) Make TeX's fonts available system-wide
Run
sudo cp $(kpsewhich -var-value TEXMFSYSVAR)/fonts/conf/texlive-fontconfig.conf /etc/fonts/conf.d/09-texlive.conf
sudo vim /etc/fonts/conf.d/09-texlive.conf
Delete the line containing type1
, save, then run
sudo fc-cache -fsv
If you use Firefox you have to add TeX Live's fonts directory, /usr/local/texlive/2019/texmf-dist/fonts/
(don't omit the trailing slash), to the variable security.sandbox.content.read_path_whitelist
in about:config
in order to allow the browser to use them [8-1]. (See 8-2 for how to use a bind-mount to avoid having to adjust the year at each installation.)
9) Install Inkscape to make the command \includesvg
work
\includesvg
is like \includegraphics
but for SVG pictures. It's provided by the LaTeX package svg
[9-1].
sudo dnf install inkscape
10) Update
su - tladmin
tlmgr update --self --all
Do not use sudo or switch to root. The whole point is that tlmgr runs as an unprivileged user and cannot touch your home or system directories.
APPENDIX
I) Upgrading to the next TeX Live
To upgrade you need to download and run the installer again, and to update the year in /etc/profile.d/texlive.sh
You can remove the old distribution(s) by running:
rm -rf /usr/local/texlive/<YEAR>
II) Uninstalling TeX Live
To remove TeX Live completely you need to undo everything you've done [2-1]:
III) Optional stuff
On [2-1] there are further instructions on
- updading via GUI;
- creating a launcher (.desktop file) for Gnome to start the GUI updater.
If you want to use tlmgr --gui
you'll need perl-Tk:
sudo dnf install perl-Tk
You might also need the dictionaries for Aspell (for instance if you use it in Emacs), which you can install with
sudo dnf install aspell-<lang1> aspell-<lang2> …
Have fun :-)
install-tl
.