"gpg: signing failed: Inappropriate ioctl for device" on MacOS with Maven

Har*_*own 1 macos homebrew gnupg maven

I have installed GPG via Homebrew with brew install gpg. It is installed in version 2.2.17.

In my Maven POM I have this snippet:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-gpg-plugin</artifactId>
    <version>1.6</version>
    <executions>
        <execution>
            <id>sign-artifacts</id>
            <phase>verify</phase>
            <goals>
                <goal>sign</goal>
            </goals>
        </execution>
    </executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)

However when running mvn clean verify I get this error:

gpg: Beglaubigung fehlgeschlagen: Inappropriate ioctl for device
gpg: signing failed: Inappropriate ioctl for device
Run Code Online (Sandbox Code Playgroud)

How can I fix this error?

Dmi*_*try 18

在 macOS 上,您可能希望使用pinentry-macGUI 窗口来输入 pin 并可选择将 pin 存储在钥匙串中。

您可以通过 Homebrew 安装它:

brew install pinentry-mac
Run Code Online (Sandbox Code Playgroud)

并在您的~/.gnupg/gpg-agent.conf配置中使用以下行启用它(如果它不存在则创建它):

pinentry-program /usr/local/bin/pinentry-mac
Run Code Online (Sandbox Code Playgroud)

  • 应用您的建议后,一旦运行了“killall gpg-agent”,它就会起作用。 (8认同)
  • 非常感谢!这可能是更好的方法,不知道为什么这没有更多的赞成票。 (3认同)
  • 对我来说,路径是 `pinentry-program /opt/homebrew/bin/pinentry-mac` (3认同)

Har*_*own 6

I have added

GPG_TTY=$(tty)
export GPG_TTY
Run Code Online (Sandbox Code Playgroud)

to my ~/.bash_profile file. Now it is working.

See also https://github.com/Homebrew/homebrew-core/issues/14737#issuecomment-309848851

  • @Amerousful 给定的两行解决方案是首选,因为它不会隐藏退出代码。(尝试 `export test=$(exit 1); echo $?`) (4认同)
  • 这个修复在我的 Linux 机器上也有效。我在将 gpg 传输到 ssh 时遇到错误。 (2认同)
  • 或`导出 GPG_TTY=$(tty)` (2认同)