Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ustulation opened this issue Jan 18, 2024 · 1 comment
Labels

Comments

@ustulation
Copy link

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.

@ustulation ustulation added the bug label Jan 18, 2024
@ustulation ustulation changed the title nix allows duplicate duplicate binaries even for different packages under certain conditions nix allows duplicate binaries even for different packages under certain conditions Jan 18, 2024
@bobvanderlinden
Copy link
Member

bobvanderlinden commented Feb 28, 2024

The expected behavior describes conflicting on name. This sometimes leads to possible issues where 2 different packages are named the same unintentionally. For instance:

$ nix profile install nixpkgs#wineWowPackages.full
$ nix profile install nixpkgs#qt6.full

This way it isn't possible to install these simultaneously.

See the discussion here: #10065

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants