It appears that this is actually a Bash thing rather than a Guile thing:
https://superuser.com/questions/132489/hostname-environment-variable-on-linux
HOSTNAME
is a variable that bash (but not other shells) sets by default. It is not exported.Since it's not exported, it will not be inherited by
env
or any C program invoked from a bash shell.
For more information about why, see the comment in this other answer which mentions that HOSTNAME
is not required for POSIX compliance:
https://superuser.com/questions/132489/hostname-environment-variable-on-linux/132500#132500
https://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap08.html
Curiously, I can reproduce this on my Guix System, but actually not on my Fedora system (where it is exported automatically), so I guess some distros choose to explicitly export the HOSTNAME
variable?