Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

automatic gpg signing doesn't seem to work #21

Closed
Sigafoos opened this issue Nov 23, 2020 · 10 comments
Closed

automatic gpg signing doesn't seem to work #21

Sigafoos opened this issue Nov 23, 2020 · 10 comments

Comments

@Sigafoos
Copy link

I automatically sign all of my commits: my ~/.gitconfig includes

[commit]
	gpgsign = true

When the plugin attempted to commit some changes, I got this error in the console:

git-error.js:32 Uncaught (in promise) Error: error: cannot run gpg: No such file or directory
error: gpg failed to sign the data
fatal: failed to write commit object

    at GitExecutorChain.onFatalException (eval at <anonymous> (app.js:1), <anonymous>:2536:85)
    at GitExecutorChain.eval (eval at <anonymous> (app.js:1), <anonymous>:2527:28)
    at Generator.throw (<anonymous>)
    at rejected (eval at <anonymous> (app.js:1), <anonymous>:2482:65)
@denolehov
Copy link
Collaborator

hey @Sigafoos, are you on Linux? If so, could you try launching Obsidian from a command line using their AppImage and see if the problem persists?

Or if you're using flatpak:

/home/$USER/.local/share/flatpak/app/md.obsidian.Obsidian/current/active/files/obsidian

@Sigafoos
Copy link
Author

Unfortunately I'm on a Mac (and Windows, though I haven't tried it there yet)

@danmichaelo
Copy link

GUI apps on Mac don't read your shell initialization files (.profile, .bashrc etc.), so they generally have a different PATH from what you get in your terminal.

So one solution would be to modify the system-wide PATH variable, but I guess the reason Homebrew or other package managers don't recommend doing this by default, is the risk of conflicts.

My preferred solution is therefore instead to tell git where it can find gpg. First, find out where gpg is located:

$ type gpg
gpg is /usr/local/bin/gpg

Then configure git to use that full path:

$ git config --global gpg.program /usr/local/bin/gpg

@Sigafoos
Copy link
Author

This worked! Thank you so much.

@agucova
Copy link

agucova commented Mar 6, 2021

I'm on Linux using the Flatpak version, with gpgsign = true and gpg.program set to /usr/bin/gpg (where it is on my case), and I can only get it to work while manually running the flatpak binary. If launched through the desktop shortcut, I get the slightly different error:

git-error.js:31 Uncaught (in promise) Error: error: gpg failed to sign the data
fatal: failed to write commit object

    at GitExecutorChain.onFatalException (eval at evalFunc (app.js:1), <anonymous>:2302:85)
    at GitExecutorChain.eval (eval at evalFunc (app.js:1), <anonymous>:2293:28)
    at Generator.throw (<anonymous>)
    at rejected (eval at evalFunc (app.js:1), <anonymous>:2247:65)

@jonatan-ivanov
Copy link

Fyi, there is another workaround: if you start Obsidian from the terminal where the environment is initialized (PATH), the Obsidian process will see the environment variables, finds gpg and commit works: open /Applications/Obsidian.app.

@dmthepm
Copy link

dmthepm commented Oct 18, 2021

This doesn't seem to work for me. I've installed homebrew so maybe that's a factor. I don't have any files on my computer called gpg. @Sigafoos any suggestions?

`Uncaught (in promise) Error: Pushing to https://github.com/dmthepm/garden.git
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/dmthepm/garden.git'

at Object.action (eval at <anonymous> (app.js:1), <anonymous>:2971:33)
at PluginStore.exec (eval at <anonymous> (app.js:1), <anonymous>:3003:33)
at eval (eval at <anonymous> (app.js:1), <anonymous>:3407:45)
at new Promise (<anonymous>)
at GitExecutorChain.handleTaskData (eval at <anonymous> (app.js:1), <anonymous>:3405:16)
at GitExecutorChain.eval (eval at <anonymous> (app.js:1), <anonymous>:3389:46)
at Generator.next (<anonymous>)
at fulfilled (eval at <anonymous> (app.js:1), <anonymous>:3317:58)
at processTicksAndRejections (internal/process/task_queues.js:93)`

@dmthepm
Copy link

dmthepm commented Oct 18, 2021

I've got two files in /localmachine/ruby -v/Library/Taps/homebrew/homebrew-core/Formula called gpg-tui.rb
& gpgme.rb. Maybe it's one of those?

@jaspermayone
Copy link

GUI apps on Mac don't read your shell initialization files (.profile, .bashrc etc.), so they generally have a different PATH from what you get in your terminal.

So one solution would be to modify the system-wide PATH variable, but I guess the reason Homebrew or other package managers don't recommend doing this by default, is the risk of conflicts.

My preferred solution is therefore instead to tell git where it can find gpg. First, find out where gpg is located:

$ type gpg
gpg is /usr/local/bin/gpg

Then configure git to use that full path:

$ git config --global gpg.program /usr/local/bin/gpg

This is working for me. Thank you!

@jasonm23
Copy link

Hi @dmthepm hopefully you figured this out. Explaining how to install/set it up and integrate with Git, and obsidian seems to be well outside the scope of this issue.

The solution to this issue, is simply about how PATH environment var is (or isn't) passed to GUI apps like Obsidian, so we can configure git to know where to find the gpg executable.

for example:

git config --global gpg.program /usr/local/bin/gpg

If you don't have gpg installed, the process is involved and not trivial for non-dev/ops/programmer people, as you'll need to install it and setup your cryptographic keys etc.

For example on mac you could look at this guide.

https://gist.github.com/troyfontaine/18c9146295168ee9ca2b30c00bd1b41e

Google will help you for other platforms/os "how do I setup GPG on X"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants