Skip to content

fix(desktop): capture zshrc-only gpg/ssh-agent env vars for signed commits - #176

Merged
devlint merged 2 commits into
mainfrom
fix/171-signed-commit-env-vars
Aug 31, 2026
Merged

fix(desktop): capture zshrc-only gpg/ssh-agent env vars for signed commits#176
devlint merged 2 commits into
mainfrom
fix/171-signed-commit-env-vars

Conversation

@devlint

@devlint devlint commented Aug 31, 2026

Copy link
Copy Markdown
Owner

Summary

  • Fixes Error on commit #171: git commit from the GUI failed with error: Couldn't get agent socket? fatal: failed to write commit object on macOS, while the identical commit succeeded from Terminal.
  • Root cause: shell_env::init_login_shell_env() backfills the minimal launchd environment of a Finder/Dock-launched GitWand.app by probing $SHELL -l -c env. On zsh, -l (login) alone does not source ~/.zshrc — only an interactive shell does, and a -c script stays non-interactive even with -l. GPG/SSH-agent setup (export GPG_TTY=$(tty), agent-socket exports from common guides like 1Password/YubiKey) is conventionally placed in .zshrc, so it never reached the process env that git commit inherits.
  • Fix: add -i to the probe ($SHELL -i -l -c env) so .zshrc-only exports are captured too, same as any other shell-rc variable.

Test plan

  • Added login_shell_flags_tests (macOS-only) that spawns real zsh against an isolated ZDOTDIR fixture with a .zshrc-only marker var: one test proves the new flags capture it, one documents that the old -l-only invocation misses it.
  • Verified red → green manually by reverting the flag and re-running the new test.
  • cargo test --lib — 250 passed, 0 failed.
  • cargo clippy --lib -- -D warnings — clean.
  • cargo fmt --check — clean.
  • CHANGELOG.md updated under [Unreleased] → Fixed.

Laurent Guitton added 2 commits August 31, 2026 09:36
…mmits (#171)

init_login_shell_env() probed `$SHELL -l -c env` to backfill the minimal
launchd env of a Finder/Dock-launched app. `-l` alone doesn't source
`~/.zshrc` on zsh (only an interactive shell does), so GPG_TTY and
agent-socket exports conventionally placed there never reached the
process env. A signed git commit from the GUI then hit gpg-agent/ssh-agent
without a working socket, while the same commit worked from Terminal.

Add `-i` to the probe so `.zshrc`-only exports are captured too.
…de error

Its only consumers (the production probe and the macOS-gated test module)
are both target_os = "macos" — gating the const on `any(test, ...)` made
it compile under `cfg(test)` on Linux too, with no user there, which
clippy's -D warnings flagged as dead code on the ubuntu-22.04 job.
@devlint
devlint merged commit 4e4a365 into main Aug 31, 2026
8 checks passed
@devlint
devlint deleted the fix/171-signed-commit-env-vars branch August 31, 2026 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error on commit

1 participant