Skip to content

nh fail to detect nix version when using nh clean all #357

@yapxuan

Description

@yapxuan

I have confirmed that this is a bug related to nnh

  • This is a bug, and not an user error or a support request. I understand that my issue will be closed if it is not a bug in NH.
  • I have checked the issues tab and confirmed that my issue has not yet been reported. I understand that my issue will be closed if it is a duplicate.

Description

It look similar to issue #353, but cannot temporary fix with only add NH_NO_CHECKS=1. I tried nh clean user and it work fine.

Log:

~ took 4s ❯ nh clean all -v
TRACE nh::logging:86: Logging OK
DEBUG nh:27: Main {
    verbose: true,
    command: Clean(
        CleanProxy {
            command: All(
                CleanArgs {
                    keep: 1,
                    keep_since: Duration(
                        0ns,
                    ),
                    dry: false,
                    ask: false,
                    nogc: false,
                    nogcroots: false,
                },
            ),
        },
    ),
}
DEBUG nh:28: NH_VERSION=4.1.2 NH_REV=Some("8cfcd3c")
DEBUG nh::util:236: "sudo" "\'--preserve-env=NIX_PATH,NIX_CONFIG,PATH,NIX_SSL_CERT_FILE,NIX_USER_CONF_FILES,NIX_REMOTE\'" "env" "\'NH_NO_CHECKS=1\'" "\'NH_FLAKE=/home/puiyq/nixos-config-flake\'" "\'USER=puiyq\'" "\'HOME=/home/puiyq\'" "/nix/store/517civ91f0daprg37b30vhq9bz0iba5h-nh-4.1.2-8cfcd3c/bin/.nh-wrapped" "clean" "all" "-v"
TRACE nh::logging:86: Logging OK
DEBUG nh:27: Main {
    verbose: true,
    command: Clean(
        CleanProxy {
            command: All(
                CleanArgs {
                    keep: 1,
                    keep_since: Duration(
                        0ns,
                    ),
                    dry: false,
                    ask: false,
                    nogc: false,
                    nogcroots: false,
                },
            ),
        },
    ),
}
DEBUG nh:28: NH_VERSION=4.1.2 NH_REV=Some("8cfcd3c")
DEBUG nh::commands:331: cmd=Exec { nix --version }
Error:
   0: Failed to extract version

Location:
   src/util.rs:97
~ ❯ NH_NO_CHECKS=1 nh clean all -v
TRACE nh::logging:86: Logging OK
DEBUG nh:27: Main {
    verbose: true,
    command: Clean(
        CleanProxy {
            command: All(
                CleanArgs {
                    keep: 1,
                    keep_since: Duration(
                        0ns,
                    ),
                    dry: false,
                    ask: false,
                    nogc: false,
                    nogcroots: false,
                },
            ),
        },
    ),
}
DEBUG nh:28: NH_VERSION=4.1.2 NH_REV=Some("8cfcd3c")
DEBUG nh::util:236: "sudo" "\'--preserve-env=PATH,NIX_REMOTE,NIX_USER_CONF_FILES,NIX_PATH,NIX_SSL_CERT_FILE,NIX_CONFIG\'" "env" "\'NH_NO_CHECKS=1\'" "\'USER=puiyq\'" "\'HOME=/home/puiyq\'" "\'NH_FLAKE=/home/puiyq/nixos-config-flake\'" "/nix/store/517civ91f0daprg37b30vhq9bz0iba5h-nh-4.1.2-8cfcd3c/bin/.nh-wrapped" "clean" "all" "-v"
TRACE nh::logging:86: Logging OK
DEBUG nh:27: Main {
    verbose: true,
    command: Clean(
        CleanProxy {
            command: All(
                CleanArgs {
                    keep: 1,
                    keep_since: Duration(
                        0ns,
                    ),
                    dry: false,
                    ask: false,
                    nogc: false,
                    nogcroots: false,
                },
            ),
        },
    ),
}
DEBUG nh:28: NH_VERSION=4.1.2 NH_REV=Some("8cfcd3c")
DEBUG nh::commands:331: cmd=Exec { nix --version }
Error:
   0: Failed to extract version

Location:
   src/util.rs:97
~ ❯ nh clean user
! Profiles directory not found, skipping: /nix/var/nix/profiles/per-user/puiyq (nh/src/clean.rs:125)

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

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

/home/puiyq/.local/state/nix/profiles/home-manager
- OK  /home/puiyq/.local/state/nix/profiles/home-manager-26-link
- DEL /home/puiyq/.local/state/nix/profiles/home-manager-25-link

> Removing /home/puiyq/.local/state/nix/profiles/home-manager-25-link
> Performing garbage collection on the nix store
492 store paths deleted, 2469.63 MiB freed``

Installation Method

NixOS (nixpkgs, pkgs.nh)

Installation Method (Other)

No response

NH Version

nh 4.1.2 (master branch)

System Information

  • system: "x86_64-linux"
  • host os: Linux 6.15.6, NixOS, 25.11 (Xantusia), 25.11.20250714.62e0f05
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.31pre20250712_b1245123
  • nixpkgs: /nix/store/n8gf8yr0571s1ld4nr6dmk143iv3rvmh-source

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions