NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.6k stars 13.76k forks source link

Biber and BibLatex incompatibility #88067

Closed ghost closed 9 months ago

ghost commented 4 years ago

Describe the bug

$ biber paper
INFO - This is Biber 2.14 (beta)
INFO - Logfile is 'paper.blg'
INFO - Reading 'paper.bcf'
ERROR - Error: Found biblatex control file version 3.4, expected version 3.7.
This means that your biber (2.14) and biblatex (3.11) versions are incompatible.
See compat matrix in biblatex or biber PDF documentation.
INFO - ERRORS: 1

Reproduction shell.nix

let
  pkgs = import <nixpkgs> {};
in
pkgs.mkShell {
  buildInputs = [
    pkgs.tectonic
    pkgs.biber
  ];
}

paper.tex

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}

\usepackage{biblatex}
\addbibresource{sample.bib}

\begin{document}
Let's cite! The Einstein's journal paper \cite{einstein} and the Dirac's 
book \cite{dirac} are physics related items. 

\printbibliography

\end{document}

sample.bib

@article{einstein,
    author = "Albert Einstein",
    title = "{Zur Elektrodynamik bewegter K{\"o}rper}. ({German})
    [{On} the electrodynamics of moving bodies]",
    journal = "Annalen der Physik",
    volume = "322",
    number = "10",
    pages = "891--921",
    year = "1905",
    DOI = "http://dx.doi.org/10.1002/andp.19053221004",
    keywords = "physics"
}

@book{dirac,
    title = {The Principles of Quantum Mechanics},
    author = {Paul Adrien Maurice Dirac},
    isbn = {9780198520115},
    series = {International series of monographs on physics},
    year = {1981},
    publisher = {Clarendon Press},
    keywords = {physics}
}

Expected behavior No errors

Notify maintainers @vcunat

Metadata

$ nix-shell -p nix-info --run "nix-info -m"
these paths will be fetched (0.05 MiB download, 0.28 MiB unpacked):
  /nix/store/vffvap9384lg9vbv4c5j33pvgqc6n1r3-bash-interactive-4.4-p23-dev
copying path '/nix/store/vffvap9384lg9vbv4c5j33pvgqc6n1r3-bash-interactive-4.4-p23-dev' from 'https://cache.nixos.org'...
 - system: `"x86_64-linux"`
 - host os: `Linux 5.4.40, NixOS, 20.09pre225673.8ba41a1e149 (Nightingale)`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.3.4`
 - channels(root): `"nixos-20.09pre225673.8ba41a1e149, home-manager"`
 - channels(me): `""`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute: biber
# a list of nixos modules affected by the problem
module:
veprbl commented 4 years ago

The version of biber that we ship corresponds to texlive.biblatex. tectonic ships with texlive 2018 (tectonic-typesetting/tectonic-staging#9). And doesn't yet have a builtin solution for biber tectonic-typesetting/tectonic#35. You can try overriding biber to version 2.11, which should be compatible.

cc @lluchs as maintainer of tectonic

simeoncarstens commented 3 years ago

I would also appreciate a fix for this. I tried overriding biber to version 2.11, but that didn't help (similar version incompatibility), at least not on the current unstable channel or on 20.03 to match with the date of @veprbl's message. The biblatex version in the current texlive derivation seems to be 3.3, which dates back to 2016, so it looks like updating biblatex would make more sense.

stale[bot] commented 3 years ago

I marked this as stale due to inactivity. → More info

maddiemort commented 2 years ago

I've just encountered this issue too.

veprbl commented 2 years ago

@nerosnm Which version of nixpkgs are you using? What is the output of:

biber --version
realpath `which latex`
bryango commented 1 year ago

Currently biber expects biber=2.17 while nixpkgs (as well as texlive) contains biber=2.19. For me the override suggested in https://github.com/NixOS/nixpkgs/issues/88067#issuecomment-630358815 works with no issue; e.g. with home-manager:

## home.nix

{ pkgs, ... }:

let

  ## source of biber v2.17
  ## ... from: https://hydra.nixos.org/build/202359527
  nixpkgs_biber217 = import (builtins.fetchTarball {
    url = "https://github.com/NixOS/nixpkgs/archive/40f79f003b6377bd2f4ed4027dde1f8f922995dd.tar.gz";
    sha256 = "1javsbaxf04fjygyp5b9c9hb9dkh5gb4m4h9gf9gvqlanlnms4n5";
  }) {};

in {

  home.packages = with pkgs; [
    tectonic  ## to be overridden below
  ];

  ## equivalent to ~/.config/nixpkgs/config.nix
  nixpkgs.config = {
    packageOverrides = pkgs: with pkgs; {
      tectonic = tectonic.override {
        ## overriding depedent biber to v2.17
        biber = nixpkgs_biber217.biber;
      };
    };
  };

}

Although this works on my end, I hope this could be upstreamed to nixpkgs itself so that we can make use of the hydra cache with no need to locally rebuild tectonic; cc maintainers: @lluchs @doronbehar. Thank you very much!

doronbehar commented 1 year ago

Tectonic is tracking this issue in https://github.com/tectonic-typesetting/tectonic/issues/893 . In general, we sort of rely on Tectonic's bundles to follow texlive releases. That's why we don't embed such hardcoding of the biber version in Tectonic - since Tectonic could update it's bundle without an update to Tectonic itself, which could fix such an issue if it arises after a Tectonic release.

Perhaps also the following Tectonic nixpkgs update will help: https://github.com/NixOS/nixpkgs/pull/237900

bryango commented 1 year ago

Indeed... Is it then possible to create some tectonic-standalone package without the biber dependency, so that we can install the appropriate versions of biber and tectonic-standalone separately, without the need to recompile the package? :thinking: Thanks!

doronbehar commented 1 year ago

Indeed... Is it then possible to create some tectonic-standalone package without the biber dependency, so that we can install the appropriate versions of biber and tectonic-standalone separately, without the need to recompile the package? thinking Thanks!

You have a point. I was the one who introduced the wrapping of tectonic with biber in https://github.com/NixOS/nixpkgs/pull/128071 ... I tend to think now that it shouldn't be that way, especially with this frequent issue of incompatibility. I pushed that as well to #237900 .

bryango commented 1 year ago

Wow nice! Thank you very much!

bryango commented 1 year ago

I have hence created a wrapper tectonic-with-biber so that one can combine the two into a single package, where the tectonic-specific biber is renamed biber-${version} to prevent conflict with the texlive biber:

## see: https://github.com/bryango/nixpkgs-config/blob/master/pkgs/tectonic-with-biber.nix
{ lib
, symlinkJoin
, makeBinaryWrapper
, tectonic
, biber
}:

symlinkJoin {
  name = "tectonic-with-biber-${biber.version}";

  ## biber is **not** directly exposed in paths
  paths = [ tectonic ];

  nativeBuildInputs = [ makeBinaryWrapper ];

  # Tectonic runs biber when it detects it needs to run it, see:
  # https://github.com/tectonic-typesetting/tectonic/releases/tag/tectonic%400.7.0
  postBuild = ''
    wrapProgram $out/bin/tectonic \
      --prefix PATH : "${lib.getBin biber}/bin"
    makeBinaryWrapper "${lib.getBin biber}/bin/biber" \
      $out/bin/biber-${biber.version}
  '';
  ## the biber executable is exposed as `biber-${biber.version}`

  inherit (tectonic) meta;
}

I am far from proficient in nix, so the package is created following https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/graphics/gimp/wrapper.nix along with the previous revision of tectonic. It can be used e.g. as an override:

{
  tectonic-with-biber = pkgs.callPackage ./pkgs/tectonic-with-biber.nix {
    ## `pkgs_biber` defined as in https://github.com/NixOS/nixpkgs/issues/88067#issuecomment-1592592840
    biber = pkgs_biber217.biber;
  };
}
## see e.g. https://github.com/bryango/nixpkgs-config/blob/master/flake.nix

I don't know whether it's good to upstream this or not. In any case, I think it may be useful to others like me, so it would be good to share this here haha.

bryango commented 9 months ago

Update: I am now trying to upstream a more polished solution via #273740. @doronbehar would you be interested in a review? :pleading_face: The PR will close this issue.