NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.27k stars 1.48k forks source link

Tar archives with hardlinks to files in the same archive fail to extract (regression) #4103

Open jekor opened 3 years ago

jekor commented 3 years ago

Describe the bug

When tar archives contain hard links to other files in the archive, they will fail to extract. The same tar archives extract successfully on earlier Nix versions.

Steps To Reproduce

  1. Create a flake with the following (non-flake) input: https://repo1.maven.org/maven2/io/prestosql/presto-server/343/presto-server-343.tar.gz
  2. nix flake list-inputs
  3. See error:
error: --- Error --------------------------------------------------------------------------------------------- nix
failed to extract archive: Hard-link target 'presto-server-343/plugin/memsql/jackson-core-2.10.4.jar' does not exist.
  1. See tar listing:
[...]
drwxr-xr-x 0/0               0 2020-09-26 08:05 presto-server-343/plugin/memsql/
-rw-r--r-- 0/0          188037 2020-09-26 08:05 presto-server-343/plugin/memsql/presto-base-jdbc-343.jar
-rw-r--r-- 0/0          349273 2020-09-26 08:05 presto-server-343/plugin/memsql/jackson-core-2.10.4.jar
[...]
drwxr-xr-x 0/0               0 2020-09-26 08:05 presto-server-343/plugin/kinesis/
hrw-r--r-- 0/0               0 2020-09-26 08:05 presto-server-343/plugin/kinesis/jackson-core-2.10.4.jar link to presto-server-343/plugin/memsql/jackson-core-2.10.4.jar
[...]

The same error is reproducible with fetchTarball.

Expected behavior

Nix 2.3.6 extracts the tar archive successfully.

nix-env --version output

nix (Nix) 3.0pre20200829_f156513

Also originally tested with the same error on nix (Nix) 2.4pre20200721_ff314f1

chkno commented 3 years ago

This can trigger when unpacking repacked channel tarballs. In nixpkgs, lib/tests/modules/disable-recursive/bar.nix and lib/tests/modules/disable-recursive/foo.nix are identical, and so get linked together when auto-optimise-store = true. If a nixpkgs tarball is built from a store path, the resulting tarball cannot be unpacked again. A workaround is to invoke tar with --hard-dereference when repacking.

stale[bot] commented 3 years ago

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

srhb commented 2 years ago

Still a problem.

ettom commented 6 months ago

Still relevant