#8770·nix

Almost all nix commands hang indefinitely

Author: crossbone-magisterCreated Aug 1, 2023Updated Oct 1, 2026
Labelsbug

Describe the bug

Every time I try to run any command, like:

  • nix-shell
  • nix-store --gc
  • nix-collect-garbage

It instantly becomes unresponsive and cannot be terminated by using Ctrl+C or kill -SIGTERM but only with kill -SIGKILL.

Additional context

By running a sample command with strace (strace --output=strace.txt nix-store --gc --print-dead -vvvvv) and inspecting the output, the following two lines continuously repeat:

mkdir("/nix/var/nix/db/db.sqlite.lock", 0777) = -1 EEXIST (File exists)
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=100000000}, NULL) = 0

After removing the folder /nix/var/nix/db/db.sqlite.lock the commands started working again as expected.

I can't deduce if the folder was there because of a failed previous command or for another reason.

Steps To Reproduce

  1. Ensure the folder /nix/var/nix/db/db.sqlite.lock exists
  2. Run any nix command
  3. Command hangs indefinitely

Expected behavior

Command probably shouldn't hang if the /nix/var/nix/db/db.sqlite.lock folder already exists.

nix-env --version output

bash
$ nix-env --version
nix-env (Nix) 2.15.0