Behaviour of kpsea re symlinks to directories

Yann Salmon contact at
Sun Mar 27 10:09:54 CEST 2022


I would not call strictly a bug because this is, iirc, a documented 
behaviour, but I would like to raise a question about how 
dir_list_search_list (?) manages symlinks to directories.

Consider the following :

mkdir -p ~/texmf/tex/latex/newfolder
touch ~/texmf/tex/latex/newfolder/thing.sty

kpsewhich thing.sty returns our file.

If we do :

mkdir -p /tmp/target
touch /tmp/target/test.sty
ln -s /tmp/target ~/texmf/tex/latex/newfolder/link

Now our local texmf has a symlink to a folder /tmp/target, containing a 

kpsewhich test.sty will not find that file, because, iiuc, arriving into 
~/texmf/tex/latex/newfolder, it does not see any folder there and thus 
does not make a recursive attempt to go beyond the files that are 
present (ie. thing.sty).

If we add

mkdir -p ~/texmf/tex/latex/newfolder/dummy

then test.sty will be found as ~/texmf/tex/latex/newfolder/link/test.sty.

I read this was done so for performance reasons.

I can personally live with this, but it is quite a possible barrier for 
people, because, unix-wise, creating a symlink to help tools find files 
and folders is common and reasonable, but having to create a dummy 
folder is not at all. I always feel ill-at-ease when I have to tell 
colleagues this…

And this is very difficult to pin down as the source of "texlive does 
not find my files despite them being accessible from local texmf !!".

So, is the performance tradeoff for doing so still occurring nowadays ? 
Would the performance be significantly decreased if the presence of 
symlinks were checked before deciding not to recur, since we list all 
files in the folder anyway ?

Thanks in advance for any insight !

Yann Salmon

More information about the tex-live mailing list.