Ubuntu – Install native texlive in parallel to repo version

12.04latextexlive

I'm still running Ubuntu 12.04 and I would like to manually install the most recent texlive. One of the first steps for the manual installation is to get rid of existing installations of texlive. However, I want to keep my default texlive installation from the Ubuntu repositories, since I have a huge number of LaTeX documents, which sometimes may rely on version-specific modifications.

Therefore my question is how to use a native texlive installation (or possible multiple) in parallel to the installation from the Ubuntu repositories? What steps in the manual installation change in order to account for an existing installation? And how do I tell my system which texlive distribution I want to use?

I think answering this question will probably answer all my related questions as well, like for instance: Is the current distribution only determined by the executables which are currently in the PATH? And if so, how can I quickly switch between the distributions? It looks like the texlive binaries in /usr/bin are not symlinks but real binaries, so I'm not sure how I can hide their existence without deleting them. And what may also be challenging: How can I find out all binaries that belong to a texlive distribution (pdftex, pdflatex, luatex, xetex, …)? Will changing the distribution automatically affect build systems/editors (like rubber/latexmk/eclipse/gedit) as well, or is it necessary to make manual changes each time?

Best Answer

  • Disclaimer: I have found a solution and it seems to work well.

    Update: I can now confirm that the procedure below works as well with Texlive 2015.

    In general it looks like working with parallel installations is easier than expected. To setup the native version I did the following:

    • Download the net installer, and extract it in a temporary location (the net installer is an interactive command line tool, allowing to modify various settings during setup).

    • Run the installer portable mode, i.e., install-tl -portable. This will bring up the main menu of the installer.

    • In this setting menu, I simply changed the TEXDIR (by pressing D) to a path within my home, e.g., ~/bin/texlive. This automatically changes the other TEXDIR* as well. I did not change anything else (installation scheme was set to scheme-full). Overall, the installation with the net installer is very convenient.

    Inspired by the documentation section "Environment variables for Unix" I created a file setenv.sh in the installation directory with the following content:

    dir=`cd \`dirname $0\` && pwd`
    export PATH="$dir/bin/x86_64-linux:$PATH"
    export MANPATH="$dir/texmf-dist/doc/man:$MANPATH"
    export INFOPATH="$dir/texmf-dist/doc/info:$INFOPATH"
    

    In order to switch to the new texlive distribution I simply source this file. So far, it looks like everything is working well with both the existing and the new texlive distribution.

    It looks like Kpathsea is the tool in texlive which is responsible for locating the different parts/directories of the distribution (Kpathsea path searching). I wrote the following script to check whether switching to the new distribution really changes all those TEXMF* directories:

    echo "which kpsexpand: `which kpsexpand`"
    echo "TEXMFDIST:       `kpsexpand '$TEXMFDIST'`"
    echo "TEXMFLOCAL:      `kpsexpand '$TEXMFLOCAL'`"
    echo "TEXMFHOME:       `kpsexpand '$TEXMFHOME'`"
    echo "TEXMFCONFIG:     `kpsexpand '$TEXMFCONFIG'`"
    echo "TEXMFSYSCONFIG:  `kpsexpand '$TEXMFSYSCONFIG'`"
    echo "TEXMFVAR:        `kpsexpand '$TEXMFVAR'`"
    echo "TEXMFSYSVAR:     `kpsexpand '$TEXMFSYSVAR'`"
    echo "TEXMFCACHE:      `kpsexpand '$TEXMFCACHE'`"
    

    Running this without sourcing my setenv.sh file gives the following output:

    which kpsexpand: /usr/bin/kpsexpand
    TEXMFDIST:       /usr/share/texmf-texlive
    TEXMFLOCAL:      /usr/local/share/texmf
    TEXMFHOME:       /home/bluenote/texmf
    TEXMFCONFIG:     /home/bluenote/.texmf-config
    TEXMFSYSCONFIG:  /etc/texmf
    TEXMFVAR:        /home/bluenote/.texmf-var
    TEXMFSYSVAR:     /var/lib/texmf
    TEXMFCACHE:      $TEXMFCACHE
    

    This shows that the standard texlive from the Ubuntu repositories is in use. After sourcing, the output becomes:

    which kpsexpand: /home/bluenote/bin/texlive/2013/bin/x86_64-linux/kpsexpand
    TEXMFDIST:       /home/bluenote/bin/texlive/2013/texmf-dist
    TEXMFLOCAL:      /home/bluenote/bin/texlive/2013/../texmf-local
    TEXMFHOME:       /home/bluenote/bin/texlive/2013/../texmf-local
    TEXMFCONFIG:     /home/bluenote/bin/texlive/2013/texmf-config
    TEXMFSYSCONFIG:  /home/bluenote/bin/texlive/2013/texmf-config
    TEXMFVAR:        /home/bluenote/bin/texlive/2013/texmf-var
    TEXMFSYSVAR:     /home/bluenote/bin/texlive/2013/texmf-var
    TEXMFCACHE:      /home/bluenote/bin/texlive/2013/texmf-var:/home/bluenote/bin/texlive/2013/texmf-var
    

    I don't fully understand why using a different binary causes all these "tex variables" to change as well. I was expecting that the binary has no information that it is part of a different distribution, but fortunately it has! Note that these "tex variables" are no unix-like environment variables (that's why it is important to use single quotes when passing them to kpsexpand). I'm a bit surprised that I did not have to modify any of them via export -- in fact, they are all undefined. But so far everything seems to be working.