lazygit icon indicating copy to clipboard operation
lazygit copied to clipboard

Lazgit does not work well with terminal based pinetry programs

Open zamlz opened this issue 1 year ago • 2 comments

Describe the bug The issue is that lazygit starts behaving weird when it tries to use a pinentry program that is terminal based. It ends up breaking the program completely.

To Reproduce Steps to reproduce the behavior:

  1. Make sure the pinentry program for SSH or GPG is set to pinentry-curses or pinentry-tty.
  2. Trigger the pinentry program by trying to push to a repo that is cloned with an SSH URL.

Expected behavior The pinentry program should take focus of the program

Screenshots

image

Version info: commit=, build date=, build source=nix, version=0.40.2, os=linux, arch=amd64, git version=2.43.0 git version 2.43.0

zamlz avatar Feb 05 '24 08:02 zamlz

in my case, this bug only appear if I have

# ~/.config/lazygit/config.yml
git:
  overrideGpg: true

when I checked the code, it will trigger this runAndStream function and probably the issue is coming from there? https://github.com/jesseduffield/lazygit/blob/master/pkg/gui/controllers/helpers/gpg_helper.go#L40

if I disable that config, it works just fine, but I still need overrideGpg so I can reword commit or patch it later

hope this information helps, thanks!

alvin883 avatar Feb 09 '24 04:02 alvin883

Okay so wait? setting it to false lets me use pinentry-curses when I create commits! Unfortunately, it does work when pushing to the repo. Probably because it's technically coming through ssh? Any recommendations for dealing with SSH

zamlz avatar Feb 14 '24 06:02 zamlz

@stefanhaller thank you for your work on this! I can't wait to try it! Do you have an eta on when will the next release be available? No worries, if that is not known yet. I'm just excited to try it because it's the only thing preventing me from using this app.

Cheers!

zamlz avatar Apr 09 '24 17:04 zamlz

RIP me doing all the work 😆

jk-ing, glad it helped other people 🥳

eldios avatar Apr 09 '24 17:04 eldios

@eldios I'm sorry, I saw the the line directly above,

stefanhaller added a commit that referenced this issue Apr 9, 2024

and I had assumed!

If I looked carefully, I would have known! Thank you for you work on this! I can't wait to try it!

zamlz avatar Apr 09 '24 17:04 zamlz

For some reason I still get this issue although it is considered fixed in a mentioned commit. My context is tmux + neovim + lazygit in WSL2 in the native windows terminal:

$ env | grep TERM
TERM_PROGRAM_VERSION=3.2a
TERM=xterm-256color
TERM_PROGRAM=tmux

I tried a bunch of settings and playing with both gpg and lazygit configs but in the end I've identified two workarounds: a) use pinentry-gtk-2 (or another graphical pinentry) which just holds lazygit waiting until the pinentry is done. you should get a X window to enter your passphrase. on return, lazygit looks fine, no scrambles. b) follow the guide here: https://sbulav.github.io/vim/neovim-signing-git-commits/#configure-gpg-to-work-with-neovim to setup loopback mode for pinentry which I did not have. In loopback mode you don't get the ncurses look.

Essentially you will need to add or edit your ~/.gnupg/gpg.conf:

use-agent
pinentry-mode loopback

and then edit your ~/.gnupg/gpg-agent.conf to allow loopback:

pinentry-program "/usr/bin/pinentry"
allow-loopback-pinentry

I'm getting now a blank Enter passphrase: prompt which works reliably and is good enough for me for a pure CLI experience. the GTK option is not that lightweight or an option at all in SSH contexts where the server should not have X packages installed.

amne avatar Aug 19 '24 14:08 amne