Vinzent03 / obsidian-git

Integrate Git version control with automatic backup and other advanced features in Obsidian.md
MIT License
6.81k stars 290 forks source link

[Bug]: passphrase is missing for gpg key #133

Open JeremiahSecrist opened 2 years ago

JeremiahSecrist commented 2 years ago

Describe the bug

Issue

when using global git configs on linux gpg fails to run properly.

Relevant errors (if available)

VM110:78 Uncaught (in promise) Error: error: gpg failed to sign the data
fatal: failed to write commit object

    at Object.action (eval at <anonymous> (app.js:1), <anonymous>:2120:29)
    at PluginStore.exec (eval at <anonymous> (app.js:1), <anonymous>:2155:29)
    at eval (eval at <anonymous> (app.js:1), <anonymous>:2594:43)
    at new Promise (<anonymous>)
    at GitExecutorChain.handleTaskData (eval at <anonymous> (app.js:1), <anonymous>:2592:16)
    at GitExecutorChain.eval (eval at <anonymous> (app.js:1), <anonymous>:2576:44)
    at Generator.next (<anonymous>)
    at fulfilled (eval at <anonymous> (app.js:1), <anonymous>:2496:28)

Steps to reproduce

Steps to reproduce
  1. Have obsidian installed on linux either flatpak or appimage
  2. configure globally for git to sign files using your yubikey or other smartcard
  3. attempt to push changes to repo with obsidian git

    Steps to solve temporarily

  4. Import global configs into local config
  5. attempt to backup using obsidian git
  6. watch it work properly

Expected Behavior

I am expecting it to work with global configurations.

Addition context

Relavent information

install type: flatpak (linux)
os: fedora silverblue
pgp setup: stored on yubikey
git version: 2.31.1
gpg version: 2.2.27

Git configs

Global (ommiting personal data)
[user]
        signingKey = [REDACTED]
        email = [REDACTED]
        name = arouzing
[commit]
        gpgsign = true
[init]
        defaultBranch = master
[credential]
        helper = store
[gpg]
        program = /usr/bin/gpg
Local (ommitting personal data)
[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
[remote "origin"]
        url = git@github.com:[REDACTED]
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master
[user]
        email = [REDACTED]
        name = arouzing

Operating system

Linux

JeremiahSecrist commented 2 years ago

After some more tinkering It seams that It s very inconsistent when dealing with gpg on linux. even after setting the local config it seams to not work corrently. willing to do any tests needed to sort this out.

Vinzent03 commented 2 years ago

I don't think this is an issue with global/local setting. Instead, the passphrase is missing to use the key.

markoph commented 1 year ago

I just hit this issue but in my case only flatpak installaton (of Obsidian) is affected. I tried to use official AppImage and auto / manual commit with signing works without issue.

Let me know if there is way how to help with debugging (I have zero knowledge of how flatpaks work so I am not promising to be helpful). I am fine with using AppImage until it is fixed so I am not rushing you, just sharing info. Thank you for your work.

ManInDark commented 1 year ago

It doesn't work for me on Windows either.

When using the commandline everything works fine, I'm prompted for my ssh-passphrase and git does its thing, but Obsidian Git complains about "permission denied (publickey). fatal: could not read from remote repository."

ManInDark commented 1 year ago

A solution for simple-git could be to add an option that is something like "Needs Passphrase" with a yes / no switch in the plugin options, and if it is set to yes then query the passphrase on startup and incorporate it like shown here (npmjs.com)

skullbunnygalaxy commented 1 year ago

Same issue on MacOS.

GPG settings are defined in global .gitconfig. GPG keychain is setup and works for me when setting up commits outside of obsidian git. The workaround of putting GPG settings into the local config works for me.

cybersholt commented 1 year ago

Same issue on Pop! OS.

Tried what @skullbunnygalaxy mentioned about adding GPG info to local config, that didn't work either.

Vinzent03 commented 1 year ago

@cybersholt How did you install Obsidian? In case you re using Flatpak, try AppImage.

zerone0x commented 1 year ago

same here on mac

iraizo commented 1 year ago

this also seems to be happening to me.

zerone0x commented 1 year ago

I use below to bypass it


git config --local commit.gpgsign false

# Read local (if never set, can be an empty value)
git config --local commit.gpgsign ```
iraizo commented 1 year ago

I use below to bypass it

git config --local commit.gpgsign false

# Read local (if never set, can be an empty value)
git config --local commit.gpgsign ```

does not help a lot when you actually want to authenticate with it..

zerone0x commented 1 year ago

I use below to bypass it

git config --local commit.gpgsign false

# Read local (if never set, can be an empty value)
git config --local commit.gpgsign ```

does not help a lot when you actually want to authenticate with it..

Anyway, it backed up automatically now