WSL 2 + systemdでユーザーインスタンスのgpg-agent.socketを動かす
WSL 2のUbuntu 24.04でwsl.confを使ってsystemdを起動している状態でも、デフォルトではsystemdユーザーインスタンスでのgpg-agent.socketは動かないようだった。たとえばsystemctl --user list-units | grep gpgやsystemctl --user status gpg-agent.socketなどで現状を見れる。 調べたところそもそも有効化されていなかったので手動で有効化した。systemctl --user enable --now gpg-agent.socket。これで動くようにはなった。
ついでに、ブートと同時にユーザーインスタンスが自動起動してログイン・ログアウトとは関係なく動き続けるように、loginctl enable-linger $USERした。このコマンドについては以下のマニュアルのとおり。
Enable/disable user lingering for one or more users. If enabled for a specific user, a user manager is spawned for the user at boot and kept around after logouts. This allows users who are not logged in to run long-running services. Takes one or more user names or numeric UIDs as argument. If no argument is specified, enables/disables lingering for the user of the session of the caller.