TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I just got told, in the comments to my answer to the question How to install "vanilla" TeXLive on Debian or Ubuntu?, that I shouldn't set the environment variable $TEXMFCNF if I install TeXLive myself (rather than letting my distribution do it for me).

I checked, and on one machine where I've installed TL2010 on top of an existing Ubuntu distribution then I hadn't set $TEXMFCNF and everything had been working just fine. On another machine, I had set $TEXMFCNF (and everything had been working just fine as well). The difference between the two machines is that on the first I have admin rights and so installed TL2010 in to /usr/local/ whereas on the other I don't and so installed TL2010 in to $HOME/local/. When I set and unset $TEXMFCNF on the second machine then I get different answers for kpsewhich texmf.cnf, but the two answers are in the same basic place. So it seems that kpsewhich can figure out where texmf.cnf is based on ... what? I'm not sure what information kpathsea has to deduce the location of texmf.cnf.

With $TEXMFCNF set to $HOME/local/texlive/2010/texmf/web2c/ then kpsewhich texmf.cnf reports $HOME/local/texlive/2010/texmf/web2c/texmf.cnf. With it unset, then kpsewhich reports /somewhere/else/texlive/2010/texmf.cnf, but $HOME/local is a symlink to /somewhere/else so these are in the same installation of TL2010. kpsewhich itself is in $HOME/local/bin but the file there is actually a symlink to somewhere in the TL texmf-tree.

Lastly, I have no idea why I started setting $TEXMFCNF. The reason why is lost in the mists of time. I suspect that it is because once long ago I was happy with the TeX installation provided for me except that I didn't like the value of the home texmf tree, so I had my own texmf.cnf which overrode this.

So, to the question(s):

  1. (the main one): Is setting $TEXMFCNF good, bad, or ugly?
  2. (the what's-going-on one): How does kpathsea even start knowing where to look? As in, it has to find a configuration file somewhere telling it where to find all the other stuff, so how does it deduce where to find it?

(To focus thoughts on that last one, I can well believe that kpsewhich can deduce something from its location; so if I copied kpsewhich in to $HOME/local/bin rather than symlinked then would that break everything?)

share|improve this question
up vote 5 down vote accepted

A partial answer: The file /usr/local/texlive/2010/texmf/web2c/texmf.cnf (on my system) contains the lines

% This definition isn't used from this .cnf file itself (that would be
% paradoxical), but the compile-time default in paths.h is built from it.
% The SELFAUTO* variables are set automatically from the location of
% argv[0], in kpse_set_program_name.
% This main texmf.cnf file is installed, for a release YYYY, in a
% directory such as /usr/local/texlive/YYYY/texmf/web2c/texmf.cnf.
% Since this file is subject to future updates, the TeX Live installer
% or human administrator may also create a file
% /usr/local/texlive/YYYY/texmf.cnf; any settings in this latter file
% will take precedence over the distributed one under texmf/web2c.
% For security reasons, it is better not to include . in this path.

That first paragraph confirms that, yes, kpsewhich uses its own location to find everything. (I also tested your suggestion of copying kpsewhich to a new place and seeing that it couldn't find anything.)

Edit: Further info: I tried setting $TEXMFCNF (it hadn't been set on my system). With $TEXMFCNF set to a list of directories, kpsewhich would look only in those directories for texmf.cnf. You can see this by setting $TEXMFCNF to a list of directories none of which contain texmf.cnf; if you then run kpsewhich texmf.cnf, it complains that it couldn't find texmf.cnf in any of those directories. Thus, if you set $TEXMFCNF, you need to be sure it includes all of the directories that contain a texmf.cnf that you want kpsewhich to search.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.