viperML / nh

Yet another nix cli helper
European Union Public License 1.2
1.02k stars 35 forks source link

! Failed to read profiles directory during cleaning #108

Closed tesarect closed 6 months ago

tesarect commented 6 months ago

Hi, im pretty new to nixos and just installed nh. I mainly wanted to try out the cleaning option first and when i did, this is what i got

nh clean all --keep 3 --dry
[sudo] password for mainuser: 
! Failed to read profiles directory dir="/root/.local/state/nix/profiles" error=Os { code: 2, kind: NotFound, message: "No such file or directory" } @ src/clean.rs:267

Welcome to nh clean
Keeping 3 generation(s)
Keeping paths newer than 0s

legend:
OK: path to be kept
DEL: path to be removed

gcroots (matching the following regex patterns)
- RE  .*/.direnv/.*
- RE  .*result.*
- DEL /home/mainuser/.dotfiles/result

/nix/var/nix/profiles/per-user/mainuser/channels
- OK  /nix/var/nix/profiles/per-user/mainuser/channels-2-link

/nix/var/nix/profiles/per-user/mainuser/profile
- OK  /nix/var/nix/profiles/per-user/mainuser/profile-10-link
- OK  /nix/var/nix/profiles/per-user/mainuser/profile-9-link

/nix/var/nix/profiles/per-user/root/channels
- OK  /nix/var/nix/profiles/per-user/root/channels-3-link
- OK  /nix/var/nix/profiles/per-user/root/channels-2-link

/home/mainuser/.local/state/nix/profiles/channels
- OK  /home/mainuser/.local/state/nix/profiles/channels-1-link

/nix/var/nix/profiles/system
- OK  /nix/var/nix/profiles/system-30-link
- OK  /nix/var/nix/profiles/system-29-link
- OK  /nix/var/nix/profiles/system-28-link
- DEL /nix/var/nix/profiles/system-27-link
- DEL /nix/var/nix/profiles/system-26-link
- DEL /nix/var/nix/profiles/system-25-link
- DEL /nix/var/nix/profiles/system-24-link

/home/mainuser/.local/state/nix/profiles/home-manager
- OK  /home/mainuser/.local/state/nix/profiles/home-manager-14-link
- OK  /home/mainuser/.local/state/nix/profiles/home-manager-13-link

> Performing garbage collection on the nix store

I approached nix discourse for this initially. Wanted to ask the maintainer if the program is trying to access the /root/.local/state/nix/profiles location, what if, if the directory is not available.

viperML commented 6 months ago

That's normal, it means the root user doesn't have the new xdg profiles. I prefer to log the warning than to silently ignore it

tesarect commented 6 months ago

So, can i just create a directory with root access and leave it or is there a better way to handle it ? And i am sorry, i dint get the part

I prefer to log the warning than to silently ignore it

May i ask how to do it ?

viperML commented 6 months ago

What you see is normal and you can ignore the message