Git: Commit in Git-GUI with GPG enabled: cannot open tty

Created on 12 Mar 2017  路  19Comments  路  Source: git-for-windows/git

  • [x] I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
    64-bit
$ git --version --build-options

git version 2.12.0.windows.1
built from commit: d4baef1cdfef9de62d43f9682a98ba57adc842e4
sizeof-long: 4
machine: x86_64
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows 7 [Version 6.1.7601] 64-bit
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt

Path Option: Cmd
SSH Option: OpenSSH
CRLF Option: CRLFCommitAsIs
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Enabled
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

When I tried to commit my changes in Git-GUI (with GPG enabled), I got this error:

commit-tree failed: gpg: cannot open tty no tty: no such file or directory

Sounds like TTY is ALWAYS busy in Git-GUI

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

Git-GUI

Just clicked on **Commit** button.
  • What did you expect to occur after running these commands?

Commit to be done.

  • What actually happened instead?

Error
commit-tree failed: gpg: cannot open tty no tt: no such file or directory

can't read "old_author": no such variable
can't read "old_author": no such variable
while executing
"commit_author_reset $old_author"
(procedure "commit_committree" line 66)
invoked from within
"commit_committree file2dfdee0 aaa11d6b4d36299c416a2fa3f09ea11123cbd7b1 D:/Desktop/PAWN/MyPrj/.git/GITGUI_EDITMSG"

  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

No.

Most helpful comment

Yea I have var GNUPGHOME with value C:\Users\Yousha\.gnupg

Solved by removing this Var and using last version of Git.

All 19 comments

it happens with github desktop and with git bash as well when it is set globally.

Im not using Github Desktop...

Just Git-GUI.

Wasn't this a general problem with Git, i.e. not Windows-specific?

The problem is this line in .gitconfig:

[commit]
gpgsign = true

Which is used for GPG

It is also from having both GNU GPG from things like git for windows + WinGPG so then it conflicts between the 2 I think.

Wasn't this a general problem with Git, i.e. not Windows-specific?

I was referring to this patch: http://git.661346.n2.nabble.com/PATCH-commit-tree-do-not-pay-attention-to-commit-gpgsign-td7655017.html

However, that commit was applied as v2.9.0-rc0~48^2, i.e. it has been with us since Git v2.9.0.

So I investigated a bit more, and it turns out that Git GUI interprets commit.gpgsign itself... and then I dug into GNU Privacy Guard's source code to figure out whether there is any way to intercept its passphrase reading from the terminal. Turns out that the only way would be to use a GPG agent which 1) would complicate the usage, and 2) is not even possible in our context because MSYS2' gpg comes without gpg-agent (no idea why).

Therefore I spent some serious time today to teach gpg a new trick: call a helper a la SSH_ASKPASS: https://github.com/Alexpux/MSYS2-packages/pull/1002

We'll see how that goes.

We'll see how that goes.

Okay, it has been merged 14 days ago, and the updated package was released yesterday.

Didn't go well, setting GPG_ASKPASS does not fix everything for me; I do get asked via GUI, but then it still fails because it wants to access /dev/tty somehow. Will have to investigate more (unless somebody else beats me to it).

Still same error:

commit-tree failed: gpg: cannot open tty no tt: no such file or directory

can't read "old_author": no such variable
can't read "old_author": no such variable
    while executing
"commit_author_reset $old_author"
    (procedure "commit_committree" line 66)
    invoked from within
"commit_committree file50c070 9a995fd9a7b49568234554079a63291a06c55c3f D:/Test/.git/GITGUI_EDITMSG"

gpgsign = true in file .gitconfig

@Yousha yes, you replicated my findings. How about digging a bit deeper so I can get some sleep?

Curiously, over a year later, I am able to get the exact same error message {except, obviously, for the .git/GITGUI_EDITMSG file location and other commit specific information on the last line} on my Debian Linux box when I currently try to do a commit from the git gui program where I do have a valid key to hand (and configured for use by Git) and I have a valid PINEntry setup (pinentry-program=/usr/bin/pinentry-x11 and I do have a suitable instance of that program which is at the specified location in my file-system and is callable from the same CLI that I run git gui from). I do have a valid GPG_TTY entry - which is not hard on a Linux box (which comes out to be /dev/pts/1 {my second uxterm terminal window FWIIW} but that is no use for you Windows users). So it appears that it is possible to get the same error on other systems so it might not be something that is specific to Git-for-Windows :man_shrugging:

Also, it seems someone on a Unbuntu Linux box is also in the same situation according to this unanswered question: https://askubuntu.com/q/1020642 .

BTW having gpgsign = true in .gitconfig is a false positive - other than it is relevant because git needs to have that setting to use gpg/gpg2 to do the whole signing thing anyhow and setting it to false just shuts that down so it is not surprising if the problem seems to go away when that is changed...

Actually, I would be very surprised if this was still a problem in Git for Windows, as it now ships with GPG 2.x, and that version does not try to talk to the user via text terminal but uses a GUI instead.

Just tested it with last version of Git but got new errors:

commit-tree failed:
gpg: keyblock resource '/c/Desktop/PAWN/c:Yousha.gnupg/pubring.kbx': No such file or directory
gpg: skipped "E859B2E77F5D8FF2" no secret key
gpg: signing failed: no secret key
error: gpg failed to sign the data

While those files are exist.

Application error:

can't read "old_author": no such variable
can't read "old_author": no such variable
while executing
"commit_author_reset $old_author"
(procedure "commit_committree" line 66)
invoked from within
"commit_committree file3ac31d0 1df0716fd9e88751875cc10baedbd07382f02b9f C:/Desktop/PAWN/.git/GITGUI_EDITMSG"

Version info:

Git-2.20.0.rc2.windows.1-64-bit
git version 2.20.0.rc2.windows.1
cpu: x86_64
built from commit: 091f41c798a35d621856c78e1420a04db633550a
sizeof-long: 4
sizeof-size_t: 8

Microsoft Windows [Version 10.0.17134.345] 64bit

Also when I tried to generate new key(via GitBASh), found some errors:

gpg: failed to create temporary file '/c/Users/Yousha/C:UsersYousha.gnupg/.#lk0x000000060007b180.Yousha-PC.9200': No such file or directory
gpg: can't connect to the agent: No such file or directory
gpg: agent_genkey failed: No agent running
Key generation failed: No agent running

I tried $ gpg --list-secret-keys --keyid-format LONG but failed:

gpg: keyblock resource '/c/Users/Yousha/C:UsersYousha.gnupg/pubring.kbx': No such file or directory
gpg: Fatal: /c/Users/Yousha/C:UsersYousha.gnupg: directory does not exist!

That directory is already exist

Version Info:

gpg (GnuPG) 2.2.11-unknown
libgcrypt 1.8.4

/c/Desktop/PAWN/c:Yousha.gnupg/pubring.kbx

This looks very wrong, as if GPG misinterpreted a path with a DOS drive prefix as if it were a path relative to your home directory.

Is it possible that you have an environment variable that is set to c:\Yousha.gnupg?

Yea I have var GNUPGHOME with value C:\Users\Yousha\.gnupg

Solved by removing this Var and using last version of Git.

I think what we could do to patch this is check within git if the environement variable that is set above would possibly conflict with git features and simple ignore that variable, wether internally unsetting it manually and resetting it after the operation is done or whatever.

I think what we could do to patch this is check within git if the environement variable that is set above would possibly conflict with git features and simple ignore that variable

But it is not a Git feature. It is an MSYS GNU Privacy Guard feature.

It is an MSYS GNU Privacy Guard feature.

(And therefore Git would be the wrong place to fix this.)

Was this page helpful?
0 / 5 - 0 ratings