-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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 profile" allows installing duplicate packages #5587
Comments
Follow-up questions:
Initial attempt: flox@efef797 |
What exactly do you mean by this? I am struggling to understand. Do you mean the |
Oh, I meant the mechanism whereby two separate packages can't provide same files. I was thinking that would prevent installing same package twice as well. It turns out that installing exactly the same package with
|
I thought |
I'm new to Nix and don't know much about Nix packages yet, but the exact-same entries from
|
Indeed:
Same thing happens when installing bash from a different version:
Note that this is with But if it is the same package it will still silently create multiple entries in profile. In addition, it also doesn't upgrade the package.
I've added this issue as part of the nix profile bad UX issue: #7966 |
I created many duplicate items with #!/usr/bin/env ruby
require "open3"
# clean up duplicate nix packages
# this should be removed after nix officially fix the duplicate packages bug
# see https://github.com/NixOS/nix/issues/5587
list, _ = Open3.capture2("nix", "profile", "list")
groups = list.split("\n").group_by { |line| line.split(" ")[1] }
# collect positions for nix profile remove
positions_to_delete = groups.map do |_, lines|
positions = lines.map { |line| line.split(" ")[0].to_i }
(positions.size > 1) ? positions[1..] : []
end.flatten
# must delete high position first, otherwise the positions would change
positions_to_delete.sort.reverse_each do |pos|
system("nix", "profile", "remove", pos.to_s)
end Now just one command to clean up duplicates before Nix fix the issue. |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/flakes-as-a-unified-format-for-profiles/29476/1 |
This issue has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/flakey-profile-declarative-nix-profiles-as-flakes/35163/7 |
#8678 has been merged. This means we can look into letting profile entries conflict based on the inferred name. Installing packages with 2 urls that infer the same profile entry name should then fail. |
Describe the bug
The "nix profile" command allows installing duplicate packages, which isn't what I expected (nix-env would reject this).
It does seem to check for conflicting binaries/files among different packages (two versions of bash, for example).
This bug is about having duplicate identical installation items, which at least seems unlikely to be intentional and easy enough to check for (I'm seeing some profile-related bits having custom
operator <
's that look likely to be useful for catching at least these trivially duplicate entries?).Steps To Reproduce
nix profile install --profile ~/test-profile nixpkgs#bash
nix profile install --profile ~/test-profile nixpkgs#bash
nix profile list --profile ~/test-profile
Expected behavior
Reject attempt to install duplicate package. Or silently keeping the first, so one can install same items repeatedly without worrying about what's already installed.
nix-env --version
outputnix-env (Nix) 2.5pre20211007_844dd90
EDIT: updated after testing conflict handling among different packages
The text was updated successfully, but these errors were encountered: