[Tex/LaTex] How does LaTeX find package files

installinglinuxtexlive

On a fresh install of TeXlive on a Linux box (Linux Mint 11) I get the following error message:

! LaTeX Error: File `scalefnt.sty' not found.

But the file is there:

$ find /usr/ -name 'scalefnt.sty'  -print
/usr/share/texmf-texlive/tex/latex/carlisle/scalefnt.sty

Why pdflatex did not find it?
Is it a bug in the TeXLive installation process?

Until now I have solved this problem by adding lines like this one :

export TEXINPUTS=$TEXINPUTS:/usr/share/texmf-texlive/tex/latex/carlisle/

in my .bashrc file.
Now I have 20+ such lines in my .bashrc.
There must be a better way to solve this problem.

— Update —
Running texhash did not solve the problem.

$ sudo texhash
[sudo] password :
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.

I think the ls-R file in /usr/local/share/ was created by texhash. It is empty. I found in the kpathsea doc how to log : export TEXMFLOG=/tmp/texmf.log. After running pdflatex I get in the log :

$ cat /tmp/texmf.log 
1309254390 /var/lib/texmf/ls-R
1309254390 /usr/local/share/texmf/ls-R
1309254390 /usr/share/texmf/ls-R
1309254390 /usr/share/texmf-texlive/ls-R
1309254390 /var/lib/texmf/web2c/pdftex/pdflatex.fmt
1309254390 /usr/share/texmf-texlive/tex/latex/base/letter.cls
1309254390 /usr/share/texmf-texlive/tex/latex/base/letter.cls
1309254390 /usr/share/texmf-texlive/tex/latex/base/size10.clo
1309254390 /usr/share/texmf-texlive/tex/latex/base/size10.clo
1309254390 /usr/share/texmf-texlive/tex/generic/babel/babel.sty
1309254390 /usr/share/texmf-texlive/tex/generic/babel/babel.sty
1309254390 /usr/share/texmf-texlive/tex/generic/babel/frenchb.ldf
1309254390 /usr/share/texmf-texlive/tex/generic/babel/frenchb.ldf
1309254390 /usr/share/texmf-texlive/tex/generic/babel/babel.def
1309254390 /usr/share/texmf-texlive/tex/generic/babel/frenchb.cfg
1309254390 /usr/share/texmf-texlive/tex/generic/babel/frenchb.cfg 

In the texlive setup I use, the files /usr/share/texmf/ls-R and /usr/share/texmf-texlive/ls-R are links to /var/lib/texmf/ls-R-TEXMFMAIN and /var/lib/texmf/ls-R-TEXLIVE respectively.

I don't understand why it does not work since the style file is in one of the ls-R files:

$ grep scalefnt.sty /var/lib/texmf/ls-R-TEXLIVE
scalefnt.sty

This looks like a bug in the texlive package installation process (in Linux Mint/Ubuntu).

Best Answer

Modern TeX distributions use kpathsea library to find the files.

If your TeX Live cannot find the file, try to run texhash to refresh the file name database. On Linux / Mac, run sudo texhash.