[Tex/LaTex] Using Biber with latexmk


With version 4.22, latexmk claims to

[s]upport the use of biber (with the biblatex package) as an alternative to bibtex for generating bibliographies, with automatic determination of whether to use bibtex or biber.

I decided to give it a go. I'm using Windows 7, Strawberry Perl, MiKTeX 2.8 (including latexmk 4.22b), Biber 0.7.3 (registered in the PATH environment variable) and TeXworks r.670 (which includes settings for latexmk). Result: While latexmk generally seemed to work fine, it always called BibTeX as bibliography backend even when the preamble of my LaTeX file embodied \usepackage[backend=biber]{biblatex}. (In contrast, Biber works fine under texify, the MikTeX equivalent to latexmk.) At first, I thought that I had missed something obvious (I'm still open for the possibility), but then I looked at latexmk.pl. Here are code lines 4204–4207:

    my $bib_program = 'bibtex';
    if ( exists $generated_log{"$bbl_base.bcf"} ) {
        $bib_program = 'biber';

So Biber should be called if some condition involving a bcf-file (biblatex/Biber control file) is satisfied. In a copy of latexmk.pl in my local texmf tree, I replaced the above code with a test for the existence (or so I think) of said bcf-file:

    my $bib_program = 'bibtex';
    if ( -e "$bbl_base.bcf" ) {
        $bib_program = 'biber';

Result: The modified latexmk correctly determines when to use Biber instead of BibTeX. (When switching from Biber to BibTeX, remnant bcf-files must be deleted manually.)

So: Have I discovered a bug in latexmk 4.22b or have I missed something obvious involving my system/TeX distribution/editor?

EDIT: To make my question more focussed: I'm interested to hear if other users of latexmk observe the same behaviour (latexmk never calling Biber). If so, I'd be happy if someone suggested a solution that — unlike my "quick fix" — doesn't involve redundant Biber runs.

EDIT 2: Herbert pointed out that Perl may behave differently in Windows vs. Linux. I will report my observations to the author of latexmk after the end of the bounty period; I'm still interested in reports from other users.

Best Answer

exists $generated_log{"$bbl_base.bcf"} does a test if the list of files %generated_log includes an entry for "$bbl_base.bcf". From my point of view such an entry is missing in the list %generated_log, the reason why the call fails. If you test it with -e which does in general the same, it works in fact of the now missing check of %generated_log. You should report it to the author. It could also be possible that some of the Perl functions have not the same behaviour as with Linux.