Subject: bug#65463: Herd `fport_write: Broken pipe` error when running `guix home reconfigure`

From: [email-masked]
Date: Tue, 14 Nov 2023 20:55:26 -0500

Just throwing out that I'm also experiencing this issue, even with a 
home configuration containing a single service, that being 
home-gpg-agent-service. I've deployed the same configuration on two 
different machines at the same checkout and only experience the issue on 
one. The other machine works flawlessly. The only distinction between 
the two is that the working machine is using Guix on a foreign 
distribution while the nonworking machine is using Guix System.

I do see the same behavior mentioned previously such as herd commands 
hanging. However, in my case there seems to be another negative symptom 
from shepherd acting this way.

Various $ gpg commands will hang (presumably when they try invoking 
gpg-agent). Trying to manually invoke $ gpg-agent --daemon fails and 
hangs indefinitely without a message. This effectively makes gpg 
unusable.

Barebones home-environment:
--8<---------------cut here---------------start------------->8---
(home-environment
    (services
     (list
      (service home-gpg-agent-service-type
               (home-gpg-agent-configuration
                (pinentry-program
                 (file-append pinentry-tty "/bin/pinentry-tty"))
                (ssh-support? #t))))))
--8<---------------cut here---------------end--------------->8---

herd status:
--8<---------------cut here---------------start------------->8---
Started:
+ gpg-agent
+ root
--8<---------------cut here---------------end--------------->8---

Interestingly when running $ gpg --card-status I see the following 
printed to the log:

shepherd.log (nonworking machine):
--8<---------------cut here---------------start------------->8---
2023-11-14 19:23:06 Spawning systemd-style service 
/gnu/store/2zgdxhbnkz8fgsb1l4xydm3nbvj66mih-gnupg-2.2.39/bin/gpg-agent.
2023-11-14 19:23:06 L2023-11-14 19:23:06 oading 
/gnu/store/kzh1x4y030drw0jrdk08nynvvyasm3c1-shepherd.conf.
--8<---------------cut here---------------end--------------->8---

shepherd.log (working machine):
--8<---------------cut here---------------start------------->8---
2023-11-14 19:43:39 Spawning systemd-style service 
/gnu/store/2zgdxhbnkz8fgsb1l4xydm3nbvj66mih-gnupg-2.2.39/bin/gpg-agent.
2023-11-14 19:43:39 Running value of service gpg-agent changed to 611.
2023-11-14 19:43:39 [gpg-agent] using fd 3 for ssh socket 
(/run/user/1000/gnupg/S.gpg-agent.ssh)
2023-11-14 19:43:39 [gpg-agent] using fd 4 for browser socket 
(/run/user/1000/gnupg/S.gpg-agent.browser)
2023-11-14 19:43:39 [gpg-agent] using fd 5 for extra socket 
(/run/user/1000/gnupg/S.gpg-agent.extra)
2023-11-14 19:43:39 [gpg-agent] using fd 6 for std socket 
(/run/user/1000/gnupg/S.gpg-agent)
2023-11-14 19:43:39 [gpg-agent] listing on: std=6 extra=5 browser=4 
ssh=3)
--8<---------------cut here---------------end--------------->8---

For some reason shepherd is rereading its configuration file instead of 
properly spawning the gpg-agent service. shepherd.conf and 
shepherd-gpg-agent-ssh-agent.scm (a file that appears in shepherd.conf) 
are identical between the two machines.

shepherd.conf (working and nonworking machine):
--8<---------------cut here---------------start------------->8---
(begin (use-modules (srfi srfi-34) (system repl error-handling)) (apply 
register-services (map (lambda (file) (load file)) (quote 
("/gnu/store/6zcvlihqs5mniw2vly4w7z39lhai2grz-shepherd-gpg-agent-ssh-agent.scm")))) 
(action (quote root) (quote daemonize)) (format #t "Starting 
services...~%") (let ((services-to-start (quote (gpg-agent ssh-agent)))) 
(if (defined? (quote start-in-the-background)) (start-in-the-background 
services-to-start) (for-each start services-to-start)) (redirect-port 
(open-input-file "/dev/null") (current-input-port))))
--8<---------------cut here---------------end--------------->8---

Sorry if this is too much or not helpful! First time on the mailing 
list.