jesseduffield / lazygit

simple terminal UI for git commands
MIT License
52.66k stars 1.84k forks source link

Lazgit does not work well with terminal based pinetry programs #3308

Closed zamlz closed 6 months ago

zamlz commented 9 months ago

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

alvin883 commented 8 months ago

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!

zamlz commented 8 months ago

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 commented 6 months ago

@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!

eldios commented 6 months ago

RIP me doing all the work 😆

jk-ing, glad it helped other people 🥳

zamlz commented 6 months ago

@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!

amne commented 2 months ago

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.

mateusdeap commented 2 months ago

@amne Thanks a lot. I was having the same issue but using WezTerm on MacOS

SMC242 commented 2 months ago

@amne I tried this and it outputs the following error:

fatal: Failed to decrypt file '/home/smc242/.password-store/git/https/azdev.companyname.com/smc242.gpg' with gpg. exit=2, out=, err=gpg: Sorry, we are in batchmode - can't get input

Any ideas? I'm using Alacritty and Git Credential Manager