IntelliJ Idea gpg failed to sign data
Asked Answered
D

5

8

i can't commit with IntelliJ and an activated gpg in config. Currently I can only do this with git bash manuel. I use windows and i found a lot of informations for OSX but that didn't helped me.

How can I use VCS in IntelliJ without doing anything about git bash?

This is the error from IntelliJ when i try to commit something.

11:52   Commit failed with error
        0 files committed, 1 file failed to commit: update
        gpg failed to sign the data
        failed to write commit object
Determinant answered 1/5, 2018 at 10:2 Comment(1)
For Windows, some instructions are in this answer which worked for automatically signing commits using IntelliJ. but OSX may be different at some pointsEntertainer
C
6

IDE is not a terminal and cannot handle the prompt issue by gpg on the command line.

As a workaround, you could create a wrapper and tell git to use it as gpg app.

Wrapper code:

# file /home/user/gpg-no-tty.sh
#!/bin/bash
/usr/bin/gpg --batch --no-tty "$@" 

and then set your git config for the repo where you want to gpg sign commits:

[gpg]
        program = /home/user/gpg-no-tty.sh

See this comment for details

Cracker answered 1/5, 2018 at 13:53 Comment(2)
Please include not just a link but the actual workaraound in your question.Switchblade
This does not work on git 2.29.2, gpg 2.2.27, and Pycharm 2020.3.5.Lissalissak
H
2

In Windows + (IntelliJ / AndroidStudio), your global git config should look like this:

user.name=<username>
user.email=<email>
user.signingkey=<key>
commit.gpgsign=true
gpg.program=<path to gpg.exe>
Hostility answered 4/4, 2019 at 13:39 Comment(0)
M
1

2023 answer:

In your ~/.gnupg/gpg.conf change (or add) the following setting:

pinentry-mode ask

If you have a pinentry-mac program available (for macOS) the GUI prompt will appear upon every new passphrase request.

The gpg+Intellij setup guide can be found here: https://www.jetbrains.com/help/idea/set-up-GPG-commit-signing.html#set-up-gpg-keys

Markswoman answered 28/2, 2023 at 11:45 Comment(0)
J
1
  • Obtain the location of the pinentry-mac using,
which pinentry-mac
  • Copy the output of above command and enter the following line to your ~/.gnupg/gpg-agent.conf file (you can use nano -w ~/.gnupg/gpg-agent.conf)
pinentry-program <output of the `which pinentry-mac` command>
  • Then, kill the gpg-agent
gpgconf --kill gpg-agent

This should solve the problem.

Jeramyjerba answered 3/3 at 7:20 Comment(0)
E
0

My experience on MacOS with Homebrew has been that pinentry-mac needs to be configured. There's no TTY in the IntelliJ git console and you don't get errors about pinentry, just the above errors about gpg failing.

❯ cat $HOME/.gnupg/gpg-agent.conf
pinentry-program /opt/homebrew/bin/pinentry-mac
allow-loopback-pinentry

❯ pinentry-mac
OK Pleased to meet you
^C

The default gpgconf seems fine.

❯ gpgconf
gpg:OpenPGP:/opt/homebrew/Cellar/gnupg/2.4.3/bin/gpg
gpgsm:S/MIME:/opt/homebrew/Cellar/gnupg/2.4.3/bin/gpgsm
keyboxd:Public Keys:/opt/homebrew/Cellar/gnupg/2.4.3/libexec/keyboxd
gpg-agent:Private Keys:/opt/homebrew/Cellar/gnupg/2.4.3/bin/gpg-agent
scdaemon:Smartcards:/opt/homebrew/Cellar/gnupg/2.4.3/libexec/scdaemon
dirmngr:Network:/opt/homebrew/Cellar/gnupg/2.4.3/bin/dirmngr
pinentry:Passphrase Entry:/opt/homebrew/opt/pinentry/bin/pinentry

gpg-agent will automatically be started as required. Then pinentry-mac can be configured to use the Keychain Access.

❯ ps x | grep gpg-agent
10867 0:00.17 gpg-agent --homedir .../.gnupg --use-standard-socket --daemon

❯ gpg-agent
gpg-agent[10869]: gpg-agent running and available
Erikaerikson answered 18/12, 2023 at 0:50 Comment(1)
In my case this worked, but I had to restart the agent.Kostman

© 2022 - 2024 — McMap. All rights reserved.