Skip to content

Conversation

@bobvanderlinden
Copy link
Member

@bobvanderlinden bobvanderlinden commented Feb 26, 2024

Motivation

Currently it is possible to install a package twice.

$ nix profile install nixpkgs#firefox
$ nix profile install nixpkgs#firefox
$ nix profile list
...
Name: firefox
...
Name: firefox-1

This change explicitly checks for duplicate entries when installing packages. It'll look like:

$ nix profile install nixpkgs#firefox
$ nix profile install nixpkgs#firefox
error: 'firefox' is already installed

To decide a duplicate, the name, attrPath and originalRef (flake:nixpkgs) should be the same.

lockedRef (github:NixOS/nixpkgs/2a34566b67bef34c551f204063faeecc444ae9da) is ignored. This is to make sure installing the package twice at any time in the future will still be a conflict.

Context

Fixes #5587
As suggested in #10065 (comment)

Priorities and Process

Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@github-actions github-actions bot added new-cli Relating to the "nix" command with-tests Issues related to testing. PRs with tests have some priority labels Feb 26, 2024
@bobvanderlinden bobvanderlinden force-pushed the profile-error-install-twice branch from 7b113c4 to 26403ac Compare February 28, 2024 18:51
@edolstra edolstra changed the title profile install: error on installing package twice profile install: warn on installing package twice Feb 28, 2024
@bobvanderlinden bobvanderlinden force-pushed the profile-error-install-twice branch from 26403ac to 6722aca Compare February 28, 2024 23:14
@bobvanderlinden bobvanderlinden force-pushed the profile-error-install-twice branch from 6722aca to 14adff1 Compare February 29, 2024 07:29
@edolstra edolstra merged commit b1586a6 into NixOS:master Feb 29, 2024
@maksbotan
Copy link

Hi! Would there be a way to make nix profile replace old instance of package?

For example, if I'm installing a tool from local repository with default.nix, and I would like to reinstall it when I update the repo.

@bobvanderlinden
Copy link
Member Author

It may be a good idea to create an issue. I can take a look at it if there is a concrete plan how that workflow should work. I think a separate flag (like --force) is need for something like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-cli Relating to the "nix" command with-tests Issues related to testing. PRs with tests have some priority

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

"nix profile" allows installing duplicate packages

4 participants