2

Question: compiling in nonstopmode in a shared folder ==> how to avoid the conflict files?

I am used to running latexmk in nonstopmode and often forget to stop it when I switch over to a new machine. As the document that I keep editing is hosted on Nutstore (a Chinese equivalent to Dropbox), two latexmk processes both running in nonstopmode shall create a lot of conflict files.

Is there a hidden setting of latexmk that can "detect" if there is another latexmk process that is also running in nonstopmode? Currently, I am compiling my tex documents using the following parameters:

latexmk.pl -pvc -pdf --synctex=-1 -src-specials -silent -time -interaction=nonstopmode filename.tex I am looking for a set of specifications that can compile in nonstopmode, yet will only start compiling if there is not an ongoing compilation process that is writing to the same directory. I can imagine dropping a project.latexmain.lock file deliberately into the working directory shall do the trick.

Detailed info of my setting:

I am using two Windows machines with the same username. And, I am running latexmk via Git-Bash, through ConEMU (a console emulator). For now, I have defined "start-up tasks" so that whenever I start ConEMU, my list of active documents (on-going projects, research journals and notes) are "loaded" (compiled in nonstopmode).

Compiler-wise, I am using MikTex.

11
  • 1
    Why don't you use a softlink to the TeX file on dropbox, and compile in a local folder?
    – user121799
    Jan 14, 2018 at 22:01
  • 1
    Latexmk maintainer here: There's nothing in the current latexmk that does this. I'll take this question as a feature request. (I've got caught by the same problem myself, with two instance of latexmk on the same machine.) There can be interesting problems because of delays between creation of the lock file on the Dropbox folder on one computer and its creation on another. But something along these lines is probably better than nothing. Jan 15, 2018 at 18:53
  • @marmot The use of a softlink from a compilation directory to the Dropbox folder is indeed one way of solving the problem. But it is often easier to work directly in the Dropbox folder, especially when the project has large numbers of files, especially graphics files generated by custom dependencies. Jan 15, 2018 at 18:57
  • @llinfeng The problem is actually not specific to nonstopmode. In any latex mode, I've found problems with files generated from one instance of latexmk being trampled on from another instance. Nonstopmode does make the problem worse. Jan 15, 2018 at 19:03
  • @JohnCollins Well, I've been doing this for years, and of course I also put softlinks to the included files. I find this much more convenient than cleaning up the junk files from my collaborators and receiving messages from dropbox that someone has changed something, which then turns out to be an aux file.
    – user121799
    Jan 15, 2018 at 19:03

1 Answer 1

2

Tentative solution: soft link (or mklink in Windows)

As @marmot has suggested, one could pick any local folder s/he would like, and have all the compilations happening in this local folder. Here goes a few clarifications that helped me understood the scenario:

  • First, such soft link can be constructed for files: thus, by issuing the following command in Windows, there is a two-way "sync" taking place between the Target and the Origin.

    mklink address_for_target.txt address_for_Origin.txt

  • As it appears to me, soft link creates a "physical copy" of the Origin file, by which I mean: I can "see" the same file in the target location. And, editing either file w.r.t. to its "true location" shall update the contents in the other location.

  • To handle picture-imports, one can create soft link for folders(directories) as well.

  • Lastly, to make backward and forward search/jumping happen, it helps to create a soft link for the project_main.tex.latexmain. (My Tex editing environment: Windows OS + GVim + latexmk (through ConEMU) + MikTeX Distribution)

Concrete steps (on Windows):

  1. Find a local folder (in my case: D:\build for testing purpose`;
  2. Create 'soft link' using mklink D:\build\main_project.tex C:\project\main_projeect.tex. (And, repeat such mklink command for all *.tex files that are sourced through \input{} function, and for project.latexmain.) A batch file my be helpful (and here is my demo: mklink.bat).
  3. Once all the "soft links" are constructed, editing files in the target directory works; and compilation runs as well.

Heads up for update

Yet, creating such mirrors for files is completely new to me, and seems would take me a lot more time to integrate into my workflow.

John Collins, our beloved Latexmk maintainer, has accepted the question as a feature request. He said in his comment that conflict files can also be generated through running two latexmk processes on the same computer. File-syncing through Dropbox is just a special case of such conflict. Awaiting for an update :)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .