Skip to content

nix allows duplicate binaries even for different packages under certain conditions #9801

@ustulation

Description

@ustulation

Describe the bug

Firstly I think this is a different issue from the one stated here: #5587 - that one says it only allows duplicates for identical everything, i.e. identical bash binaries all of which have the same path in the nix-store.

Here, I encountered that we can have conflicting binary names even for non-identical packages but in a slightly less straight-forward setup. The conflicting binaries should have a non-current priority and then they are silently allowed to exist as the non-current priority (i.e lower priorities) don't make it to the bin/ of the current profile.

Steps To Reproduce

  • Add some registry entries:
nix registry add foo0 github:NixOS/nixpkgs/<commit-hash-0>
nix registry add foo1 github:NixOS/nixpkgs/<commit-hash-1>
nix registry add foo2 github:NixOS/nixpkgs/<commit-hash-2>
nix registry add foo3 github:NixOS/nixpkgs/<commit-hash-3>
  • install a pkg, say jq from any one of the flake alias above:
nix profile install foo0#jq
  • That'll be installed with a default priority (of 5 currently). Installing another version will conflict unless you give a different priority. However I can give the exact same priority for all others as long as it's other than the currently chosen priority (5) for the pkg:
nix profile install foo1#jq --priority 6
nix profile install foo2#jq --priority 6
nix profile install foo3#jq --priority 6
  • This is not great as priority 6 doesn't have a jq that can be unambiguously chosen. This problem will manifest much later when I decide to uninstall the currently chosen priority for jq (5). Check output of current profile's manifest.json to get the index position of jq with priority 5. Say that's position 3 (verify via nix profile list but that's not going to give you the priority (as of writing this), so you need to check manifest.json anyway).
nix profile remove 3                   # <<<<<<<<<<<<<< FAILS

removing 'flake:my3#legacyPackages.aarch64-linux.jq'
error: Unable to build profile. There is a conflict for the following files:

         /nix/store/1gakxx73xxza318d4rypjnpxacqf5gya-jq-1.6-man/share/man/man1/jq.1.gz
         /nix/store/glvdkn0gwmvhry67ic4sza18js0xbfc0-jq-1.6-man/share/man/man1/jq.1.gz
  • I suppose it fails because it can't decide which of the jq binaries to choose for the putting into the new profile-version's bin/ dir (and correctly so)

Expected behavior

If more than 1 binary with the same name are competing for the same priority, nix profile install <...> --priority <n> should fail instead of silently passing and the problem manifesting much later at other points (such as on nix profile remove <n> above.

nix-env --version output

2.19.2

Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions