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):
- (the main one): Is setting
$TEXMFCNFgood, bad, or ugly? - (the what's-going-on one): How does
kpathseaeven 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?)