9

I'm using latexmk with pdflatex to compile my thesis, with biblatex for references and biber as backend. It compiles fine and creates correct PDF output. If a change to the source files introduces an error the first run of pdflatex fails but a bcf file is created. The run of biber then complains about a malformed bcf file indicating that the last biblatex run failed and the compilation is stopped. However, after fixing the error latexmk thinks the pdflatex run was fine and invokes biber, but the bcf file is still malformed. latexmk somehow doesn't seem to notice that there were file changes.

Removing the bcf file or cleaning it with latexmk -C makes latexmk call pdflatex first and recreate a correct bcf file. Calling pdflatex manually also work but defeats the purpose of latexmk. I tried to use -halt-on-error as option to pdflatex but that doesn't work. I seem to recall that it worked with TexLive 2014, after a failed attempt to run biber latexmk would run pdflatex first on the next attempt.

I'm using TexLive 2015, the version of latexmk is 4.43a, biber has the version 2.3. The output produced is

Latexmk: This is Latexmk, John Collins, 5 February 2015, version: 4.43a.
Rule 'biber thesis': File changes, etc:
   Non-existent destination files:
      'thesis.bbl'
------------
Run number 1 of rule 'biber thesis'
------------
------------
Running 'biber  "thesis"'
------------
Latexmk: applying rule 'biber thesis'...
INFO - This is Biber 2.3
INFO - Logfile is 'thesis.blg'
ERROR - thesis.bcf is malformed, last biblatex run probably failed. Deleted thesis.bbl
INFO - ERRORS: 1
Latexmk: Failed to find one or more biber source files:
  NONE
Collected error summary (may duplicate other messages):
  biber thesis: Could not find all biber source files for 'thesis'
Latexmk: Use the -f option to force complete processing,
 unless error was exceeding maximum runs of latex/pdflatex.
Biber error: [33] Utils.pm:163> ERROR - thesis.bcf is malformed, last   biblatex run probably failed. Deleted thesis.bbl
Latexmk: Errors, so I did not complete making targets

Obligatory mwe.tex:

\documentclass[paper=a4]{scrartcl}

\usepackage[backend=biber]{biblatex}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\addbibresource{Bibliography.bib}

\begin{document}
\autocite{smith_pixel_1995}
\end{document}

Bibliography.bib

@article{smith_pixel_1995,
    title = {A Pixel Is Not A Little Square, A Pixel Is Not A Little Square, A Pixel Is Not A Little Square!},
    volume = {6},
    url = {http://ftp.alvyray.com/Memos/CG/Microsoft/6_pixel.pdf},
    journaltitle = {Microsoft Computer Graphics, Technical Memo},
    author = {Smith, Alvy Ray},
    urldate = {2016-02-04},
    date = {1995}
}

Steps to reproduce:

  1. run latexmk -pdf mwe
  2. introduce an error in mwe.tex like an undefined control sequence
  3. run latexmk -pdf mwe
  4. when prompted abort compilation with by pressing x
  5. fix error
  6. run latexmk -pdf mwe -> biber error
  7. run latexmk -pdf mwe -> same biber error, won't go away

So the question is, how do I get latexmk to re-create the bcf file so that biber can use it without having to manually clean or remove files?

alefhar
  • 93
  • 1
  • 5
  • 1
    I don't use latexmk, but doesn't the option -f as mentioned in your log ("Latexmk: Use the -f option to force complete processing,") work? Or run simply once pdflatex instead of latexmk. – Ulrike Fischer Feb 19 '16 at 11:42
  • @UlrikeFischer Yes, -f works. But as I see it, the point of latexmk is not to have to reprocess everything from scratch; as a quick workaround it's still a solution. – alefhar Feb 19 '16 at 11:52
  • Actually I can't reproduce your problem. If I change the tex-file, e.g. add an x, and then start latexmk it always calls pdflatex first and so also repairs a broken bcf. – Ulrike Fischer Feb 19 '16 at 12:09
  • That's what I feared. Just to be sure, you are using the same version of latexmk as I? – alefhar Feb 19 '16 at 12:13
  • You can just re-run latexmk after the failed Biber run without doing anything else and everything will work fine - provided you have fixed the problem in the TeX file and it compiles without errors. See the discussion in issue #348 at the biblatex bugtracker. (I think the latexmk developer is also active here, so he might drop by and give some more info.) – moewe Feb 20 '16 at 08:13
  • @moewe Thanks, I didn't consider to look for biblatex bugs. From what I gather from the comments in the bugreport the endless biber error loop affects not only me and is not fixed yet. For now, I'll thinks it's easiest to simply invoke latexmk with the -gg switch and recompile everything from scratch. – alefhar Feb 20 '16 at 10:19
  • I don't think this is a bug per se. It is not that easy to decide what the intended behaviour ought to be (other than, make it work of course). I believe -gg is a bit of an overkill, just run latexmk again if the compilation stops with the .bcf malformed error. This places a tiny bit more responsibility on you, but it doesn't force latexmk to redo everything from scratch. – moewe Feb 20 '16 at 16:44
  • Sorry to comment again, but I just realised you said something about an "infinite loop". That is not something I ever got, a second run always worked fine (provided the problem was solved, of course). Can you reproduce (or give a recipe to reproduce) the infinite loop? – moewe Feb 20 '16 at 16:54
  • @moewe I added some more steps, the biber error always happens. The behavior I observe is the same dbitouze describes in his comment in the discussion of the issue you linked. My biber and latexmk versions match, the biblatex version probably too. That is the bug I was referring to; the circular dependency John Collins describes, that is difficult to resolve correctly, I accept. – alefhar Feb 20 '16 at 17:06
  • I have the same problem. If you fix the error in the tex, latexmk will still run biber first which aborts due to crippled bcf. Least trouble for me is removing the crippled file. – Johannes_B Feb 20 '16 at 17:12
  • Mhhh, when I do the same, in step 7 I get a smooth compilation starting with pdfLaTeX and not the error from step 6. – moewe Feb 20 '16 at 17:12
  • @moewe It happens for me since I switched to the current biber version (2.3), with 1.8 and latexmk from TexLive 2014 on the second try pdflatex was run. – alefhar Feb 20 '16 at 17:16
  • You get the warning Latexmk: Use the -f option to force complete processing, unless error was exceeding maximum runs of latex/pdflatex. I don't think that more than this can be done on the latexmk side. – egreg Feb 20 '16 at 17:17
  • Yes, I gather that is because the handling of malformed .bcfs was changed with Biber version 2.2/2.3 (or therabouts) and between latexmk 4.39 and 4.43a. I have Biber 2.3, biblatex 3.2, latexmk 4.43a. I mght be doing something horribly wrong (or rather right), but I still struggle to reproduce step 7 in your recipe above. – moewe Feb 20 '16 at 17:21
  • I'm putting some code in latexmk to fix this. Meanwhile, one work around is to delete the offending .bcf file by hand. (Note that how problem shows itself depends on the exact versions of both latexmk and biber.) – John Collins Feb 24 '16 at 13:39
  • I've put a corrected version (4.44) of latexmk at http://users.phys.psu.edu/~collins/latexmk/ It should fix the problems described in the question, and I plan to submit this to CTAN shortly. But it would be useful for some regular users of biber to test the updated version to ensure the fix doesn't cause some other problem. (I am not a regular user of biber, so I have only tested the new version on very simple examples.) – John Collins Feb 24 '16 at 15:55
  • @JohnCollins Thanks for the support. I gave 4.44 a quick test with the MWE and my thesis and it looks pretty good so far. latexmk is detecting that biber failed due to a malformed bcf file and is running pdflatex instead. Just as I expected. Again, thanks! – alefhar Feb 25 '16 at 08:42

2 Answers2

5

As already mentioned in a comment, the solution is to use the new version of latexmk (4.44 at the time I write this answer), which is now available at http://www.ctan.org/pkg/latexmk/

John Collins
  • 11,183
  • 3
  • 32
  • 33
1

Update May 2019 March 2020:

This is still an issue with 18.04 LTS of Ubuntu (bionic), because they deliver version 4.41.

As stated by John this is fixed since version 4.44. Newer versions of latexmk are delivered for cosmic, disco, eoan, focal,..

There are at least three ways to upgrade, choose one of them:

a) Download and install the .deb package manually, e.g. from https://packages.ubuntu.com/focal/all/latexmk/download and hopefully it does not require any further dependencies to be upgraded.

b) I fixed that issue on my machine, by temporarily use the cosmic repository:

  1. edit /etc/apt/sources.list at line of universe repo from bionic to cosmic, save
  2. apt update
  3. apt install latexmk
  4. revert changes in /etc/apt/sources.list
  5. apt update

Both is in general not recommended, but latexmk is a very simple app/script with few dependencies. Pinning is not required because hopefully the maintainer won't choose a version between 4.41 and 4.44, current version in cosmic is 4.59.

c) Another approach would be loading the newest package from CTAN and install it like in the documentation, basically replace and adjust permissions. See How can I upgrade latexmk / why very old version is contained in Ubuntu repository?.

  • Just download the .deb file from https://packages.ubuntu.com/focal/all/latexmk/download and install it manually. No need to mess with the system sources. – leezu Mar 24 '20 at 21:17