TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Not sure if this is a strictly appropriate question (I hope so, because it has to do with TeX-related tools) but I need to know whether or not my texliveonfly.py script runs successfully on OS X. Unfortunately, I don't have access to a mac, or I would test it myself! While it seems theoretically solid, I need practical test results before submitting the update to CTAN.

Steps to testing:

0) Please make sure you have python 3 (can be downloaded here). Python 2 should be available by default (though feel free to try using python 3 as well).

1) Right click and save this link as texliveonfly.py and make sure the file is executable. (Addendum: if you just want to read the script, see here.)

*Update: Script is now version 1.10 and should graphically prompt you for the admin password. Furthermore, run with option --speech_when=always to test the speech-synthesized notifications.*

2) Create a minimal .tex file of the following form (though, of course, you should feel free to test with arbitrary .tex files):


\usepackage{package(s) you have not yet downloaded}
\usepackage{package(s) you have not yet downloaded}


3) Run the command texliveonfly.py yourfilename.tex in a terminal (once assuring everything's in the same folder, of course).

Expected output: new terminals should pop up, at least one asking your sudo password in order to perform updates. The new terminals should quit when they're done. Most will start with text similar to:

This is texliveonfly.py's 'install packages on the fly' feature.

Attempting to install LaTeX packages [packagenames].

The terminals might take 3-20 seconds to pop up, depending on internet connection (the tlmgr repository access is slower than you're used to). Several may pop up in total, because what the script does is keeps recompiling and searching for missing package errors until there are none left.

Should the script fail to update packages or for whatever reason, please paste its terminal output somewhere (if it's too long, perhaps on pastebin!)

If the applescript command is somehow messed up (unlikely), there is also the possibility of an infinite loop. Just Ctl + C or kill your terminal if that's the case, though please wait a while to allow for repository lag.

(As of version 1.00, the default compiler is now the more mainstream "pdflatex". You can change it by, for example, texliveonfly.py --compiler=lualatex yourfilename.tex).

Additional things you can test for, if you're feeling eager:

  1. The script should allow you to interact with the compiler when you don't pass -interaction=nonstopmode. You can do this by setting --arguments="" in the texliveonfly.py command.

  2. The script should provide (with a few added lines) the same terminal output as your compiler.

    And finally, the ultimate test:

  3. The script should allow you to, starting from a minimal TeX Live installation, download precisely the additional packages you require.

share|improve this question
it can be a good answer to this question: tex.stackexchange.com/questions/14268/… – alfC Sep 25 '11 at 5:47
Very well, I'll give it a shot. – scallops Sep 25 '11 at 8:58
note: The script relies in tlmgr, so if you have a preinstalled distribution of TeXLive (e.g. Ubuntu) you will not have tlmgr. To have tlmgr it seems that you need to have your own local TeXLive distribution in the first place. See commnets at tex.stackexchange.com/questions/14268/…. It still can be useful if you start from a minimal manual TeXLive installation. – alfC Oct 4 '11 at 2:13
yeah, it's mainly for building up a minimal installation to your individual needs. – scallops Oct 4 '11 at 2:41
On my OS X 10.10, os.name yields posix. This should be fixed by replacing the condition with platform.system() == 'Darwin', see this post. (Do not forget to include platform.) – Franklin Yu Oct 13 '15 at 5:32

(I would have left a comment, but I don't have enough credit, so I need to post an answer.)

Assume that I install a Minimal scheme. Then your script is not able to help me:

> python texliveonfly.py --compiler=lualatex hello.tex 
texliveonfly.py: Unable to start lualatex; are you sure it is installed?

The same is true if I try --compiler=context. Also, with the following input:

\definevimtyping [RUBY]  [syntax=ruby]
hello world


python texliveonfly.py --compiler=texexec test.tex


python texliveonfly.py --compiler=context test.tex

work as intended. When context is installed (but not ConTeXt modules), I would expect from the command to fetch context-vim and context-filter.

By the way: there is an option MKTEXTEX in kpathsea:

--enable-mktextex-default: This parameter is used so that TeX will automatically invoke mktextex if TeX source is missing.

that could be used to automatically trigger downloads when a package is missing. You should talk to Norbert Preining about it.

share|improve this answer
When lualatex itself does not exist, it cannot be used as a compiler. I considered having my script autobuild it, but I don't think that should be in its scope. I'll try some context tests (I admit I haven't really used it, so any information about the "missing file/package" errors it provides would be useful.) Finally, (not to be impolite; I genuinely need this info) were you testing on a mac? Thanks! – scallops Oct 6 '11 at 1:01
Yes, I know that one cannot use lualatex as a compiler unless it is installed, but MikTeX would install it on the fly for example (you would need a list of binaries either from tlpdb or from somewhere else). ConTeXt returns "system : module xyz not found", but I would expect from the script to also catch missing fonts, not just modules. And yes, I was testing on Mac OS X 10.7. – Mojca Miklavec Oct 8 '11 at 23:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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