【问题标题】:"gpg: signing failed: Inappropriate ioctl for device" on MacOS with Maven带有 Maven 的 MacOS 上的“gpg:签名失败:设备的 ioctl 不合适”
【发布时间】:2019-08-21 12:15:43
【问题描述】:

我已经通过 Homebrew 使用 brew install gpg 安装了 GPG。 它安装在版本2.2.17

在我的 Maven POM 中,我有这个 sn-p:

<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

我该如何解决这个错误?

【问题讨论】:

  • 尝试使用-X 参数运行maven 以找到实际执行的gpg 命令行。
  • @JimmyB 不幸的是,使用-X 时没有打印任何 gpg 命令。

标签: macos maven homebrew gnupg


【解决方案1】:

我已经添加了

GPG_TTY=$(tty)
export GPG_TTY

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

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

【讨论】:

  • 这个修复也适用于我的 linux 机器。将 gpg 导入 ssh 时出现错误。
  • export GPG_TTY=$(tty)
  • @Amerousful 给定的两行解决方案是首选,因为它不会隐藏退出代码。 (试试export test=$(exit 1); echo $?
【解决方案2】:

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

你可以通过 Homebrew 安装它:

brew install pinentry-mac

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

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

【讨论】:

  • 在应用您的提案后运行 killall gpg-agent 后,它就会起作用。
  • 非常感谢!这可能是更好的方法,不知道为什么没有更多的赞成票。
【解决方案3】:

试试这个

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

【讨论】:

    【解决方案4】:

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

    【讨论】:

      【解决方案5】:

      如果有人在 bash 中输入 gpg 命令时收到此错误消息,请尝试添加 --no-tty。这为我解决了问题。

      【讨论】:

        猜你喜欢
        • 2022-06-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-12-08
        • 1970-01-01
        • 2014-09-17
        • 2021-09-21
        • 1970-01-01
        相关资源
        最近更新 更多