0

I work on a paper with a collaborator via git. Some of us have different latex versions, in particular biblatex 3.9 and biblatex 3.11 are used.

If author A compiles the document and runs biber, then a doc.bbl file with biber version 2.11 is created. If then author B makes some changes and tries to compile the error

Package biblatex Warning: File 'doc.bbl' is wrong format version - expected 2.9. 

appears. The only solution at this point is to delete doc.bbl manually and recreate it in version 2.9.

Can one somehow automate this process? How can I tell my compiler to delete bbl files if a version mismatch is detected?

  • 3
    Why do you exchange the bbl via git? Simply put it in your .gitignore. – Ulrike Fischer Jul 13 '18 at 11:49
  • 3
    If both do a complete update ... Problem gone – Johannes_B Jul 13 '18 at 11:50
  • 1
    I agree with Ulrike that there is no good reason to exchange the temporary files (not only .bbl, but also .bcf, .aux, ...). Related: tex.stackexchange.com/q/410512/35864. If you only share the .tex and .bib files you (1) have to share and transfer fewer files and (2) should both be able to compile with your local versions with less hassle. – moewe Jul 13 '18 at 11:52
  • Is there any latex solution to this problem? In other setting I sometimes collaborate via Dropbox or shared file servers where ignoring certain file extensions is not possible. – Julian Jul 13 '18 at 12:05
1

Ideally, you would avoid sharing the temporary files (.aux, .bbl, .bcf, ...) with your colleague. Only share the non-temporary important files (.tex, .bib, images, ...). See Matching biblatex in two machines for more explanations why sharing temporary files is usually bad and can go wrong.

Sophisticated systems like Git have a way to ignore certain files and so does Dropbox https://superuser.com/q/469776. Even if your preferred method does not have a way to selectively ignore a file, a simple script that delete temporary files before submission might be simpler here.

If you must share the temporary files, a simple clean-up script that get rids of temporary files before compilation (see for example Deleting external/auxiliary files?) sounds like the best solution to me. Of course this file would not be called before every compilation, just before the first compilation after a sync. You could make the script cleverer by checking if the versions are wrong first (you'd have to parse the right part of the .bbl and would have to compare with the expected version of your biblatex installation, which seems possible, but fiddly).

Here is a LaTeX-based solution that overwrites .bbl files of the wrong version with an empty file by opening it and closing it immediately afterwards.

\documentclass[british]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{csquotes}

\usepackage[style=authoryear, backend=biber]{biblatex}

\addbibresource{biblatex-examples.bib}

\makeatletter
\newwrite\blx@jul@deletefile@out

% copy of the original macro from biblatex.sty
\def\blx@ifsigned#1#2{%
  \begingroup
  \let\blx@tempa\@firstoftwo
  \edef\blx@tempb{\csuse{blx@sig@#2}}%
  \edef\blx@tempb{\detokenize\expandafter{\blx@tempb}}%
  \openin\blx@bcfin #1.#2\relax
    \ifeof\blx@bcfin
    \else
      \endlinechar\m@ne
      \readline\blx@bcfin to \blx@tempc
      \ifeof\blx@bcfin
      \else
        \ifx\blx@tempb\blx@tempc
          \readline\blx@bcfin to \blx@tempc
          \edef\blx@tempb{\csuse{blx@ver@#2}}%
          \edef\blx@tempb{\detokenize\expandafter{\blx@tempb}}%
          \ifx\blx@tempb\blx@tempc
          \else
            \blx@warning@noline{%
              File '#1.#2' is wrong format version - expected \blx@bblversion}%
            \let\blx@jul@deletefile@do\@empty% <- added
          \fi
        \else
          \blx@error
            {File '#1.#2' not created by biblatex}
            {This file was apparently not created by biblatex.
             Rename it or\MessageBreak move it to a location were
             TeX will not find it. If this error\MessageBreak
             persists, consider redefining \string\blxauxsuffix.%
             See the biblatex\MessageBreak manual for details}%
          \let\blx@tempa\@secondoftwo
        \fi
      \fi
    \fi
  \closein\blx@bcfin
  \ifundef\blx@jul@deletefile@do% <- this conditional is new
    {}
    {\blx@warning@noline{Deleting file #1.#2}%
     \immediate\openout\blx@jul@deletefile@out #1.#2\relax
     \immediate\closeout\blx@jul@deletefile@out
     \global\undef\blx@jul@deletefile@do}%
  \expandafter\endgroup\blx@tempa}
\makeatother

\begin{document}
\cite{sigfridsson}
\printbibliography
\end{document}

I wouldn't do that, but if you insist on a LaTeX solution this is pretty universal.

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.