Subject: bug#74949: guix describe crash if HOME is unset OR /etc/passwd is missing

From: Simon Josefsson <[email-masked]>
Date: Wed, 18 Dec 2024 18:25:00 +0100

Hi

I get the backtrace below.  Setting either HOME to something, or adding
an entry to /etc/passwd for the running user, silences this.

I don't think it should fail like this, should it?

Is a reasonable behaviour to assume HOME means "/" when unset?

How to handle missing /etc/passwd entries probably depends on what the
code wants to use it for.

/Simon

jas@kaka:~/src/guix-container$ podman run --entrypoint /bin/sh -it registry.gitlab.com/debdistutils/guix/container:latest
sh-5.1# guix describe
Backtrace:
In ice-9/boot-9.scm:
   222:29 19 (map1 _)
   222:29 18 (map1 _)
   222:29 17 (map1 _)
   222:29 16 (map1 _)
   222:29 15 (map1 _)
   222:29 14 (map1 _)
   222:29 13 (map1 _)
   222:29 12 (map1 (((guix packages)) ((guix profiles)) ((guix #)) ?))
   222:17 11 (map1 (((guix profiles)) ((guix derivations)) ((# #)) ?))
  3327:17 10 (resolve-interface (guix profiles) #:select _ #:hide _ # ?)
In ice-9/threads.scm:
    390:8  9 (_ _)
In ice-9/boot-9.scm:
  3253:13  8 (_)
In ice-9/threads.scm:
    390:8  7 (_ _)
In ice-9/boot-9.scm:
  3544:20  6 (_)
   2836:4  5 (save-module-excursion #<procedure 7fe582a23b10 at ice-?>)
  3564:26  4 (_)
In unknown file:
           3 (primitive-load-path "guix/profiles" #<procedure 7fe582?>)
In guix/profiles.scm:
  2388:23  2 (_)
In guix/utils.scm:
  1071:48  1 (xdg-directory _ "/.config" #:ensure? _)
In unknown file:
           0 (getpw 0)

ERROR: In procedure getpw:
In procedure getpw: entry not found
sh-5.1# export HOME=/
sh-5.1# guix describe
  guix 790c9ff
    repository URL: https://git.savannah.gnu.org/git/guix.git
    branch: master
    commit: 790c9ffe596e3deabf175e030adee5fb706aa981
sh-5.1# exit
jas@kaka:~/src/guix-container$ podman run --entrypoint /bin/sh -it registry.gitlab.com/debdistutils/guix/container:latest
sh-5.1# guix describe
Backtrace:
In ice-9/boot-9.scm:
   222:29 19 (map1 _)
   222:29 18 (map1 _)
   222:29 17 (map1 _)
   222:29 16 (map1 _)
   222:29 15 (map1 _)
   222:29 14 (map1 _)
   222:29 13 (map1 _)
   222:29 12 (map1 (((guix packages)) ((guix profiles)) ((guix #)) ?))
   222:17 11 (map1 (((guix profiles)) ((guix derivations)) ((# #)) ?))
  3327:17 10 (resolve-interface (guix profiles) #:select _ #:hide _ # ?)
In ice-9/threads.scm:
    390:8  9 (_ _)
In ice-9/boot-9.scm:
  3253:13  8 (_)
In ice-9/threads.scm:
    390:8  7 (_ _)
In ice-9/boot-9.scm:
  3544:20  6 (_)
   2836:4  5 (save-module-excursion #<procedure 7fac35694b10 at ice-?>)
  3564:26  4 (_)
In unknown file:
           3 (primitive-load-path "guix/profiles" #<procedure 7fac35?>)
In guix/profiles.scm:
  2388:23  2 (_)
In guix/utils.scm:
  1071:48  1 (xdg-directory _ "/.config" #:ensure? _)
In unknown file:
           0 (getpw 0)

ERROR: In procedure getpw:
In procedure getpw: entry not found
sh-5.1# echo 'root:x:0:0:root:/root:/bin/bash' > /etc/passwd
sh-5.1# guix describe
  guix 790c9ff
    repository URL: https://git.savannah.gnu.org/git/guix.git
    branch: master
    commit: 790c9ffe596e3deabf175e030adee5fb706aa981
sh-5.1#