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 profile remove '.*' doesn't remove path installabes #7487

Closed
erikarvstedt opened this issue Dec 20, 2022 · 3 comments · Fixed by #10166
Closed

nix profile remove '.*' doesn't remove path installabes #7487

erikarvstedt opened this issue Dec 20, 2022 · 3 comments · Fixed by #10166
Labels
bug good first issue Quick win for first-time contributors profiles Versioned gc root symlinks; nix profile, nix-env

Comments

@erikarvstedt
Copy link
Member

Reproduce

nix profile install $(nix build --no-link --print-out-paths nixpkgs#hello) --profile /tmp/nix-profile 
nix profile remove '.*' --profile /tmp/nix-profile
# Result:
# warning: '.*' does not match any packages
# warning: Use 'nix profile list' to see the current profile.

Expected behavior

nix profile remove '.*' should "Remove all packages", as suggested in --help.

nix-env --version output

nix-env (Nix) 2.12.0

Priorities

Add 👍 to issues you find important.

@roberth roberth added the profiles Versioned gc root symlinks; nix profile, nix-env label Mar 29, 2023
@bobvanderlinden
Copy link
Member

Hmm, indeed. The currently implementation of regex doesn't look at store paths:

nix/src/nix/profile.cc

Lines 522 to 527 in 67f9575

if (auto path = std::get_if<Path>(&matcher)) {
if (element.storePaths.count(store.parseStorePath(*path))) return true;
} else if (auto regex = std::get_if<RegexPattern>(&matcher)) {
if (std::regex_match(name, regex->reg))
return true;
}

An alternative approach is to introduce a more explicit way to upgrade all packages (like using --all): #10162

@iFreilicht
Copy link
Contributor

@roberth I think this could be marked good first issue. @bobvanderlinden already marked the part of the code that has to be changed, the only other thing a contributor needs to figure out is how to add this case to the functional tests.

@roberth roberth added the good first issue Quick win for first-time contributors label Mar 6, 2024
@bobvanderlinden
Copy link
Member

@iFreilicht Sry! I was already reworking the way packages are matched in nix profile in #10166. This issue will also be resolved if the PR is an acceptable solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue Quick win for first-time contributors profiles Versioned gc root symlinks; nix profile, nix-env
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants