Some time ago I updated from TeX Live 2014 to 2015. Now I want to sometimes compile a file with last year's version. It seems to be enough to just specify the full path of the executable on the command line, i.e. /usr/local/texlive/2014/bin/x86_64-linux/xelatex
, as the messages of the packages loaded all mention the 2014 directory. Or is there still something I don't see which pulls in stuff from 2015?
For each YYYY version of TeX Live which I have installed, I set up two symbolic links as follows:
cd /usr/local/texlive
ln -s <YYYY>/bin/x86_64-linux/
ln -s current.<YYYY> <YYYY>/
For the active version, I then do
ln -s bin.<YYYY> bin
ln -s current.<YYYY> current
For example, right now, it looks like this:
drwxr-xr-x 11 texlive texlive 4096 Mai 20 2012 2011/
drwxr-xr-x 10 texlive texlive 4096 Ebr 11 2013 2012/
drwxr-xr-x 9 texlive texlive 4096 Ebr 22 2014 2013/
drwxr-xr-x 9 texlive texlive 4096 Ebr 15 23:15 2014/
drwxr-xr-x 9 texlive texlive 4096 Gor 25 22:11 2015/
lrwxrwxrwx 1 texlive texlive 8 Meh 17 00:36 bin -> bin.2015/
lrwxrwxrwx 1 root root 21 Rha 12 2011 bin.2011 -> 2011/bin/x86_64-linux/
lrwxrwxrwx 1 texlive texlive 21 Gor 21 2012 bin.2012 -> 2012/bin/x86_64-linux/
lrwxrwxrwx 1 texlive texlive 21 Meh 29 2013 bin.2013 -> 2013/bin/x86_64-linux/
lrwxrwxrwx 1 texlive texlive 21 Meh 20 2014 bin.2014 -> 2014/bin/x86_64-linux/
lrwxrwxrwx 1 texlive texlive 21 Meh 12 02:03 bin.2015 -> 2015/bin/x86_64-linux/
lrwxrwxrwx 1 texlive texlive 12 Meh 17 00:36 current -> current.2015/
lrwxrwxrwx 1 texlive texlive 4 Ion 17 2012 current.2011 -> 2011/
lrwxrwxrwx 1 texlive texlive 4 Gor 21 2012 current.2012 -> 2012/
lrwxrwxrwx 1 texlive texlive 4 Meh 29 2013 current.2013 -> 2013/
lrwxrwxrwx 1 texlive texlive 4 Meh 20 2014 current.2014 -> 2014/
lrwxrwxrwx 1 texlive texlive 4 Meh 12 02:03 current.2015 -> 2015/
drwxr-xr-x 11 texlive texlive 4096 Gor 25 22:11 texmf-local/
I then create a script part as /etc/profile.d/<some_name_with_texlive>.sh
with the following content:
if [ `whoami` != "root" ]
then
[ -d "/usr/local/texlive/bin" ] && export PATH="/usr/local/texlive/bin:${PATH}"
fi
Note that this deliberately does not change the PATH
of the root
user for security reasons.
EDIT
The settings above are enough to access MAN pages but they are not sufficient for them to be indexed. To ensure that MAN pages are indexed and that man -k
or apropos
can find them when searching, I did the following. This is likely to be more system-dependent than the earlier part of this answer, so tread with care and adapt to your system's existing configuration.
The first thing I did was to make a backup copy of /etc/man_db.conf
and then open the original for editing.
In the section mapping parts of the PATH to parts of MANPATH, I added the following line:
MANPATH_MAP /usr/local/texlive/bin /usr/local/texlive/current/texmf-dist/doc/man/
In the part mapping MANPATHs to CATPATHs, I added this line:
MANDB_MAP /usr/local/texlive/current/texmf-dist/doc/man/ /var/cache/man/texlive
I then saved the changes.
So far, this doesn't do much good because the index of MAN pages is created by a process running as root. Since root's PATH doesn't include /usr/local/texlive/bin
, the mappings do not help.
To address this, you need to know which process compiles the index on your system. The index is usually updated automatically on a regular schedule e.g. once per day.
This might be managed by a utility called cron
or anacron
or similar. If so, you may find details in something like /etc/crontab
or /etc/cron.daily/<some-script>
.
On my system, the indexing is now controlled by systemd
. The default files controlling it are /usr/lib/systemd/system/man-db.service
and /usr/lib/systemd/system/man-db.timer
.
The `.service file has the following content:
[Unit]
Description=Update man-db cache
RequiresMountsFor=/var/cache/man
[Service]
Type=oneshot
ExecStart=/usr/bin/mkdir -m 0755 -p /var/cache/man
ExecStart=/usr/bin/mandb --quiet
Nice=19
IOSchedulingClass=best-effort
IOSchedulingPriority=7
and the .timer
file is as follows:
[Unit]
Description=Daily man-db cache update
[Timer]
OnCalendar=daily
AccuracySec=12h
Persistent=true
As you might guess, the .timer
file just tells systemd
to update the index on a daily basis. No need to change that.
I therefore copied just the .service
file to /etc/systemd/system/man-db.service
and added the following line to the [Service]
section:
Environment=PATH=${PATH}:/usr/local/texlive/bin
This means that, when indexing the MAN pages, root's PATH will have /usr/local/texlive/bin
added to the existing PATH. This will then get mapped to the appropriate MANPATH and CATPATH, since I've already set these mappings up in /etc/man-db.conf
.
So, the complete systemd
unit file in /etc/systemd/system/man-db.service
:
[Unit]
Description=Update man-db cache
RequiresMountsFor=/var/cache/man
[Service]
Type=oneshot
Environment=PATH=${PATH}:/usr/local/texlive/bin
ExecStart=/usr/bin/mkdir -m 0755 -p /var/cache/man
ExecStart=/usr/bin/mandb --quiet
Nice=19
IOSchedulingClass=best-effort
IOSchedulingPriority=7
Note 2 things:
- root's PATH is only altered for this single task and not more generally;
- even for this task, the addition to the PATH is added to the end of root's PATH and not to the beginning, as in the case when configuring ordinary users' default PATHs.
Both provide greater security than would altering root's PATH along with the PATHs of ordinary users.
And the results? apropos pdflatex
- which only yesterday found nothing appropriate
- today suggests the following MAN pages:
pdflatex (1) - PDF output from TeX
purifyeps (1) - make an Encapsulated PostScript file work with both dvips and pdflatex
You've got two texlive installations:
/usr/local/texlive/2014/
/usr/local/texlive/2015/
For your personal use, it is not necessary to change anything there. Just put into the file
/home/<username>/.profile
a line like
PATH=/usr/local/texlive/2014/bin/x86_64-linux:$PATH; export PATH
Save the file, log out (no need to reboot), log in again and you are on texlive 2014.
At least this is how I do I do it on openSuse since 2009.
I'm quite sure that there are better and easier ways. Probably a developer who has to maintain different versions of his package won't always log in an out.
Maybe you can for your cases have a second user on your machine and so you'd just have to switch between users. But this won't work out of the box, if one user owns the files you'd like to compile.
When you install a texlive (I do it with symbolic links for the binaries) all is in the directory :
/usr/loca/share/texlive/2014
or 2015
the binaries are links (for me) in /usr/local/bin
pointing on the last installed 2014 or 2015 previously seen directory.
the environment variables and pathes are set on the last installation (2014 or 2015) previously seen directory (the same as binaries).
You just have switch between 2015 and 2014 directories using links :
rename /usr/loca/share/texlive/2014
as /usr/loca/share/texlive/old
rename /usr/loca/share/texlive/2015
as /usr/loca/share/texlive/new
In the /usr/loca/share/texlive/
directory make a link called 2015
or 2014
(depending of witch is the last texlive installed) pointing on old
or new
depending on witch texlive you want to use.
I now did the following:
$ sudo ln -s /usr/local/texlive/2014 /usr/local/texlive/active
Edited /etc/profile.d/texlive.sh
such that the only uncommented lines are
export PATH=/usr/local/texlive/active/bin/x86_64-linux:$PATH
export MANPATH=/usr/local/texlive/active/texmf-dist/doc/man:$MANPATH
export INFOPATH=/usr/local/texlive/active/texmf-dist/doc/info:$INFOPATH
Then I rebooted, but surely there is an easier way of resetting the path.
Now TeX Live 2014 was active. To switch back to 2015:
$ sudo rm /usr/local/texlive/active
$ sudo ln -s /usr/local/texlive/2015 /usr/local/texlive/active
Which indeed could be put in a script.
-
2If you are using a modern GNU/Linux distribution, do not set MANPATH or INFOPATH. These are no longer necessary and it is actually harmful to set them. In modern distros, they are generated on-the-fly based on PATH. If you set the variable, you risk ending up only having accessing to TeX man/info pages.
echo $MANPATH
andecho $INFOPATH
both return an empty line for me and all works great. – cfr Aug 7 '15 at 1:41 -
@cfr I took out the $MANPATH and $INFOPATH variables, as they are not necessary for man to find the manpages. They didn't seem to create any problem though, the normal manpages also functioned. – muk.li Aug 7 '15 at 14:49
-
Hmm... Interesting. In that case, I don't know. I thought that was why it was bad to set it explicitly but maybe it isn't. I do know it is better to not do so. I guess now I'm just not entirely sure why. – cfr Aug 7 '15 at 19:08
xdvipdfmx:fatal: Something is wrong. Are you sure this is a DVI file?
, so I guess $PATH is necessary. – muk.li Aug 6 '15 at 18:48