running TeX tools from non-standard locations

In some configurations (for example, when using MacTeX), if you copy a TeX-related binary to non-standard location, the tool stops working. More precisely, if a tool uses kpathsea library, special setup is required. More practically, is you compile something like dvisvgm, it might not work.

Discussion: pointing kpathsea to the correct texmf tree.

Summary: texmf.cnf defines search paths in terms of SELFAUTO* variables (at least, in vanilla TeXLive and MacTeX 2009). Therefore, kpathsea looks for files relative to the location of the calling program.

Therefore, to find the files, the calling program should be located in the right place or all the AUTO-based search paths should be redefined. For me, the following wrapper implements the second idea:

----- textool.sh: begin

#!/bin/bash

for i in         \
  TEXMFMAIN      \
  TEXMFDIST      \
  TEXMFLOCAL     \
  TEXMFSYSVAR    \
  TEXMFSYSCONFIG \
  TEXMFCNF       
do
  export $i=`kpsewhich -expand-var "$"$i` 
done

"$@"


----- textool.sh: end

Running kpsewhich in a wrong location doesn't work:

$ ./kpsewhich psfonts.map
warning: kpathsea: configuration file texmf.cnf not found in
these directories: ...
$ export export TEXMFCNF='{/usr/local/texlive/2009/.....
$ ./kpsewhich psfonts.map
$

But the wrapper helps:

$ textool.sh ./kpsewhich psfonts.map
/usr/local/texlive/2009/texmf-var/fonts/map/dvips/updmap/psfonts.map
$ textool.sh ./a.out 
psfonts.map=/usr/local/texlive/2009/....../psfonts.map
$

Categories: TeX

Updated: