I have an unusual situation. My deployment environment needs to place pdfTeX and associated files into a custom directory that is not known until deploy time, and changes from one server to the next in a relatively random way. I.e. I cannot pre-install TeX on the server, and I cannot install anything into standard directories such as /etc, /usr/local, or the user's home directory. Everything needs to go into a custom directory like /path/to/deploy/here/somerandomstring.

Is there a way to make pdfTeX run such that it will look for files such as latex.fmt only in directories that I tell it to look in at runtime using some combination of command line arguments and environment variables?

  • 3
    I have never tried it myself, but there's an option in TeX Live that allows an installation on a USB stick. This should also solve your issue. – Uwe Ziegenhagen Jan 16 '14 at 20:13
  • 1
    You can also override TeX's variables on the command line e.g. TEXMFHOME=/path/to/nonexistent/directory pdflatex filename.tex will ignore anything in my real TEXMFHOME. (And setting it to an existent directory would use the contents of that directory.) So you could presumably do the same for variables specifying the other texmf trees. – cfr Jan 16 '14 at 23:08

Assuming a usual TeX Live system on Linux, what determines where the binaries look for files is the path they are in. As such, if you 'point' to the correct pdftex executable with the correct path set up then you'll find the correct files. For example, if we install our TeX system into /path/to/deploy/here/somerandomstring then we want

export PATH=/path/to/deploy/here/somerandomstring/texlive/bin/x86_64-linux:$PATH

assuming a 64-bit install.

You can arrange to set up much of this in an automated fashion. The LaTeX team do this for automated testing: see out installation script and TeX Live profile. The idea with these is that the installation has to run as a 'normal' user and needs to be somewhat customised, but the basic idea is to set the PATH variable to a place we can write to then either install TeX there or find it if its already present. The installation profile is a separate file here as we don't need to create it on-the-fly, but it could be generated by the script if the path can't be determined in advance (presumable you have some way of being notified what location to use, and this can be passed to a script).

  • 1
    It's not clear from the question if searching additional location has to be forbidden. That can easily be achieved by updating texmf.cnf. – Joseph Wright Dec 29 '15 at 16:01
  • Note you can get the installer to tell your script whether it's going for 32- or 64-bit so you could make that part variable, but I'd hope you have some idea of the nature of the target system! – Joseph Wright Dec 29 '15 at 16:11

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.