在使用 Maven 的 MacOS 上“gpg:签名失败:设备的 ioctl 不合适”

问题描述 投票:0回答:5

我已经通过 Homebrew 使用

brew install gpg
安装了 GPG。 它安装在版本
2.2.17

在我的 Maven POM 中,我有这个片段:

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

但是运行时

mvn clean verify
我收到此错误:

gpg: Beglaubigung fehlgeschlagen: Inappropriate ioctl for device
gpg: signing failed: Inappropriate ioctl for device

如何修复此错误?

macos maven homebrew gnupg
5个回答
146
投票

我已添加

GPG_TTY=$(tty)
export GPG_TTY

到我的

~/.bash_profile
文件。现在它正在工作。

另请参阅https://github.com/Homebrew/homebrew-core/issues/14737#issuecomment-309848851


43
投票

在 macOS 上,您可能需要使用

pinentry-mac
来让 GUI 窗口输入 PIN 码,并可选择将 PIN 码存储在钥匙串中。

您可以通过 Homebrew 安装它:

brew install pinentry-mac

并在您的

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

pinentry-program /usr/local/bin/pinentry-mac

3
投票

试试这个

gpg --use-agent --armor --detach-sign --output $(mktemp) pom.xml

1
投票

对我来说,发生这种情况是因为终端窗口不够大,无法容纳密码 TUI。一旦我打开一个更大的终端选项卡,然后重新运行 gpg 命令,我就能够看到密码终端用户界面。


0
投票

如果有人在 bash 中输入

gpg
命令时收到此错误消息,请尝试添加
--no-tty
。这为我解决了问题。

© www.soinside.com 2019 - 2024. All rights reserved.