I have a header.tex file sitting in $TEXMFHOME/tex/latex/ and I tried using \input in another .tex file in some other directory. Note that kpsewhich is able to find header.tex, printing its full path, and I have also applied texhash on my $TEXMFHOME directory.

However, pdflatex does not seem to be able to locate the file.

I have tried going through both the documentation for kpathsea and pdflatex for pointers. The pdflatex states that $TEXINPUTS is the search path for \input files. And so I appended $TEXMFHOME to that environment, which I believe I should not need to, but alas.

  • 2
    Welcome to TeX.SX! Usually one should not apply texhash to $TEXMFHOME nor use $TEXINPUTS. – egreg Feb 15 '18 at 0:11
  • What's the exact text of the error message you get and what's the minimal code you try compiling to get that message? – cfr Feb 15 '18 at 0:35
  • @egreg Thank you. I do understand that and I had a similar setup in another system, and I did not have to fiddle with texhash and $TEXINPUTS. But I had to give them a try to see if it leads me anywhere. – Japorized Feb 15 '18 at 1:23
  • @cfr I will add that to my original post. – Japorized Feb 15 '18 at 1:24
  • 1
    It depends a bit on what the solution is. If your question is a duplicate, we can close it with a link to the duplicate. If the problem is due to something like a typo, we'd usually just close it with some not-quite-fitting-reason-as-we-can-only-pick-from-multiple-choice. Otherwise, you should answer the question. You shouldn't put your answer in the question. – cfr Feb 15 '18 at 2:44

I failed to mention that I was using texliveonfly, which is a my mistake when asking my question. To run texliveonfly, I need sudo so that texliveonfly can install missing packages, just as you would need sudo rights to install packages via tlmgr if your system is set up that way.

The problem lies in the fact that the environment that the task is in when you run as sudo is different from your user environment. In the case of when I am running as sudo, $TEXMFHOME does not point to any directory, and hence it could not find my files.

Now I can either set up a $TEXMFHOME for root, or use $TEXMFLOCAL instead. I went with the later and that solved my problem.

  • I have to say that the idea of compiling with root privileges fills sends a chill down my spine. I won't even run tlmgr with root privileges or install-tl. Compiling as root cannot possibly be considered safe, surely, do the texliveonfly developers seriously recommend this? – cfr Feb 15 '18 at 23:47
  • It depends on the structure of how tlmgr was installed. If you require sudo to install packages with tlmgr, then texliveonfly can only ask for the same, which is why I mentioned that "if your system is set up that way". – Japorized Feb 16 '18 at 17:50
  • But, since people standardly do install that way, that is the standard case. I'm amazed anybody would even consider using it this way. – cfr Feb 17 '18 at 0:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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