Follow by Email

Friday, August 17, 2012

Administering TeX Live on Ubuntu

The TeX that comes in the Ubuntu package manager is a couple of years old (I have Ubuntu 12.04 LTS here in 2012 and the package manager has TeX Live 2009).  For many people that won't matter but for my text Linear Algebra I needed some more recent packages, which needed a more recent LaTeX kernel ... . So on the urging of a number of smart folks I installed TeX Live 2012 from tug.org.  Here is my experience.

I kept the package manager's packages installed.  One reason is that I know from past experience that if I drop those packages then when I want to install related materials from the package manager, such as AUCtex or Asymptote, then the package manager will complain about unmet dependencies, and I'll try a --force install  and later there will be an update ... and anyway at some point so that chaos sets in.  (Lars Madsen posted a way to avoid this with his knowledge of the package system but of the choices available I went another way, partly because I didn't entirely understand his process and so would have trouble adjusting it if I needed to.)

A first go


I downloaded TeX Live.  It put things in the default of /usr/local/texlive.   My local files go in /usr/local/texlive/texmf-local.  I changed the PATH variable in /etc/profile (maybe I should have used /etc/environment instead, or in addition?) and logged out and back in again.

To check  my setup I copied some personal styles and classes.

    ftpmaint@millstone:~$ ls /usr/local/texlive/texmf-local/tex/latex/local
    charis.sty  gentium.sty  memo.cls  present.sty
    conc.sty    jh.sty       mins.cls  pyweb.cls

I tried to remake the file database


    ftpmaint at millstone:~$ sudo texhash
    [sudo] password for ftpmaint: 
    texhash: Updating /usr/local/share/texmf/ls-R... 
    texhash: Updating /var/lib/texmf/ls-R-TEXMFMAIN... 
    texhash: Updating /var/lib/texmf/ls-R-TEXLIVE... 
    texhash: Updating /var/lib/texmf/ls-R... 
    texhash: Done. 
 
but after then issuing kpsewhich conc.sty failed.  Why?

Turns out (I am skipping over a great deal of head-scratching and googling here), on Ubuntu the sudo command was using the Ubuntu tex's texhash
 
    ftpmaint at millstone:~$ which texhash
    /usr/local/texlive/2012/bin/i386-linux/texhash
    ftpmaint at millstone:~$ sudo which texhash
    /usr/bin/texhash

rather than tug.org's because it has its own PATH.

    ftpmaint at millstone:~$ echo $PATH
    /usr/local/texlive/2012/bin/i386-linux:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games
    ftpmaint at millstone:~$ echo 'echo $PATH' | sudo sh
    /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

Oops.

I got around it by calling the program with its full path.

    ftpmaint at millstone:~$ sudo /usr/local/texlive/2012/bin/i386-linux/texhash
    texhash: Updating /usr/local/texlive/2012/texmf/ls-R... 
    texhash: Updating /usr/local/texlive/2012/texmf-config/ls-R... 
    texhash: Updating /usr/local/texlive/2012/texmf-dist/ls-R... 
    texhash: Updating /usr/local/texlive/2012/../texmf-local/ls-R... 
    texhash: Updating /usr/local/texlive/2012/texmf-var/ls-R... 
    texhash: Done.

The answer


The above was an answer, but it obviously wasn't the answer.  Lars commented, "On my systems I have a specific LaTeX user who owns the LaTeX installation, thus I do not have to run anything as root."  This seemed right.

I created a new user texlive to own the material in /usr/local/texlive.

    ftpmaint at millstone:~$ cd /usr/local    
    ftpmaint at millstone:~$ sudo chown -R ftpmaint:ftpmaint texlive

A comment about this user: I don't want texlive to appear on the choices on the login screen so I gave this account a user id below 500: sudo usermod -u 499 texlive (I got the parameter 500 from /etc/lightdm/users.conf).

Several people cautioned me to watch the umask of this user but because the system sets the default at 022 I was OK. 

 Lars mentioned that he may have multiple TeX Live trees under /usr/local/texlive, say /usr/local/texlive/2011 and /usr/local/texlive2012.  He has a soft link that points to the current one.

    texlive at millstone:~$ ln -s 2012 current

I often have trouble remembering what command options to run, etc., so I like to put that stuff in .sh files.  Here the soft link does its magic; no need to change the script when I add another tree.

     ftpmaint@millstone:/usr/local/texlive$ ls -l
    total 12
    drwxr-xr-x 10 texlive texlive 4096 Aug 17 07:05 2012
    lrwxrwxrwx  1 root    root       4 Aug 16 17:47 current -> 2012
    drwxr-xr-x 10 texlive texlive 4096 Aug 17 07:05 texmf-local
    -rwxr--r--  1 texlive texlive  181 Aug 16 17:48 update.sh
 
    ftpmaint@millstone:/usr/local/texlive$ cat update.sh
    #!/bin/bash
    # Update the current TeX Live installation
    # 2012-Aug-16 Jim Hefferon jhefferon@smcvt.edu
   
    PATH=/usr/local/texlive/current/bin/i386-linux:$PATH
    tlmgr update --all --self

The only remaining hiccup is to remember the password for texlive.  This is the kind of account that a person only uses every couple of months where I could easily forget.  But I use a password keeper program KeePassX to store my passwords so I put this user's information in there.

    
 

No comments: