V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
The Go Programming Language
http://golang.org/
Go Playground
Go Projects
Revel Web Framework
proxytoworld
V2EX  ›  Go 编程语言

goland 在 wsl2 git commit 签名时报错

  •  
  •   proxytoworld · 197 天前 · 836 次点击
    这是一个创建于 197 天前的主题,其中的信息可能已经有所发展或是发生改变。

    在使用 goland 的 git 尝试提交时会出现如下错误

    error: gpg failed to sign the data:
    [GNUPG:] KEY_CONSIDERED ...... 2
    [GNUPG:] BEGIN_SIGNING H10
    [GNUPG:] PINENTRY_LAUNCHED 1401 gnome3:curses 1.2.1 - xterm-256color :0.0 - 1000/1000 -
    gpg: signing failed: Inappropriate ioctl for device
    [GNUPG:] FAILURE sign 83918950
    gpg: signing failed: Inappropriate ioctl for device
    fatal: failed to write commit object
    

    因为配置了 GPG 签名,commit 时要输入 GPG 密钥的密码,网上查找错误,都让配置export GPG_TTY=($tty),我把这个加到了~/.zshrc,但使用 goland 提交时还是会这样

    我在 goland 的 terminal 手动 git commit 时能够正常弹出

    5 条回复    2023-10-18 13:49:48 +08:00
    chancefyi
        1
    chancefyi  
       196 天前
    遇到过这个问题,很烦,成为我放弃 wsl 的原因之一
    LindsayZhou
        2
    LindsayZhou  
       196 天前   ❤️ 2
    我不用 goland ,不过提供一些思路
    1. .zshrc 是不一定会执行的,参考 https://medium.com/@rajsek/zsh-bash-startup-files-loading-order-bashrc-zshrc-etc-e30045652f2e 。放到 .zshenv 里应该更合适一点。
    我不知道 goland 是怎么运行的。不过我的 VPS 用 ssh remote env 的方式能够确定 .zshrc 没有被执行

    2. 你可以尝试一下在 ~/.gnupg/gpg-agent.conf 里加上 cache 配置

    default-cache-ttl 86400
    max-cache-ttl 604800

    然后运行一下 gpgconf --kill gpg-agent 关掉旧的 gpg-agent 。再到终端里随便签个名,这样 gpg-agent 里就有了 cache ,一段时间内不会再要输入密码。
    zed1018
        3
    zed1018  
       196 天前
    @LindsayZhou 方案 2 牛皮,我就是因为这个所以不想给自己添堵就没有给 gpg 加密码。

    不过 OP 可以试试 gateway 里跑 wsl goland 能避免很多莫名其妙的问题,JB IDEs 的 wsl 支持总体上差 vscode 很多。
    proxytoworld
        4
    proxytoworld  
    OP
       196 天前
    @LindsayZhou
    感谢#2 提供的方案 2 实测有效
    使用了方案 1 后依然出错,不过是不一样的错
    20:30:23.140: [glog] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false commit -F /mnt/c/Users/user/AppData/Local/Temp/git-commit-msg-.txt --
    方案 2 有效 也就不折腾方案 1 了
    LindsayZhou
        5
    LindsayZhou  
       195 天前
    @proxytoworld #4 盲猜是 goland 去调用 git 的时候,没有给 tty
    ```
    > ssh tei env | grep GPG
    GPG_TTY=not a tty
    ```

    cache 里放那么久可能需要注意一下安全性,我是用物理密钥,拔了就 cache 失效了。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2298 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 02:55 · PVG 10:55 · LAX 19:55 · JFK 22:55
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.