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

Check for existing store path in nix profile #4524

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

matthewbauer
Copy link
Member

Previously, nix profile allowed you to install if they had the same
store path.

For instance, you could do:

$ nix profile install github:nixos/nixpkgs#hello
$ nix profile install nixpkgs#hello

This leads to duplication since multiple elements are the same path.
It could also cause issues when upgrading when two elements have the
same store path at one point, but then diverge later, leading to
conflicts.

The new error message looks like:

error: Cannot install 'github:nixos/nixpkgs#hello' when its store path (/nix/store/lwl497mzqp0k7cfhh51c948nkagc3bbr-hello-2.10) is already installed through 'github:nixos/nixpkgs#legacyPackages.x86_64-linux.hello'

Previously, nix profile allowed you to install if they had the same
store path.

For instance, you could do:

$ nix profile install github:nixos/nixpkgs#hello
$ nix profile install nixpkgs#hello

This leads to duplication since multiple elements are the same path.
It could also cause issues when upgrading when two elements have the
same store path at one point, but then diverge later, leading to
conflicts.

The new error message looks like:

  error: Cannot install 'github:nixos/nixpkgs#hello' when its store path (/nix/store/lwl497mzqp0k7cfhh51c948nkagc3bbr-hello-2.10) is already installed through 'github:nixos/nixpkgs#legacyPackages.x86_64-linux.hello'
@@ -260,11 +273,14 @@ struct CmdProfileInstall : InstallablesCommand, MixDefaultProfile

std::visit(overloaded {
[&](BuildableOpaque bo) {
checkForExistingPath(*installable, bo.path);

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, but why a blank line only here and not around 283 as well?

@edolstra
Copy link
Member

Maybe it's better to check this in ProfileManifest::build(). For instance, nix profile upgrade can also cause multiple profile elements to resolve to the same store path.

@matthewbauer
Copy link
Member Author

multiple

Yeah that sounds fine. It's a little bit less clear what the user should do in that case, but at least it's better than the original error message.

It's kind of an unusual scenario to have two paths installed in a profile that point to different store paths then converge to one store path in a nix profile upgrade run. I think it can happen, but every case I can think of would have collisions preventing you from installing them in the first place.

@stale
Copy link

stale bot commented Aug 24, 2021

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

@stale stale bot added the stale label Aug 24, 2021
@Ericson2314
Copy link
Member

I recall some recent changes had something to do with this?

@stale stale bot removed the stale label Jun 14, 2023
@bobvanderlinden
Copy link
Member

This is covered by #10090

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

Successfully merging this pull request may close these issues.

None yet

5 participants