obsidian-git icon indicating copy to clipboard operation
obsidian-git copied to clipboard

[1Password, ssh-agent] Error: cannot run op: No such file or directory

Open richban opened this issue 8 months ago • 11 comments

Image

My ssh-agent is running, and it's working as intended but for some reason obsidian-git can't find op.

plugin:obsidian-git:376 obsidian-git: Error: error: cannot run op: No such file or directory
warning: gpg.ssh.defaultKeyCommand failed:  
error: user.signingKey needs to be set for ssh signing
fatal: failed to write commit object

richban avatar Mar 18 '25 08:03 richban

When creating an issue on a repo, please use the appropriate suggested issue template. Like the bug template in this case. This makes the resolving of your issue much easier and requires fewer questions. Do you know what that op file should be? Can you the file from the terminal? If so, I guess it's a PATH problem and Obsidian doesn't know where to find that file.

Vinzent03 avatar Mar 18 '25 20:03 Vinzent03

Yes, I should have used the template thanks for pointing out. Yes I can run the op and it's in the PATH, not sure why obsidian doesn't know where to find it.

richban avatar Mar 20 '25 13:03 richban

You probably installed it to some location, which is only added to your PATH in your shell session like .bashrc or .zshrc. Please share the location of the op binary and add the parent directory to additional path env vars in the plugin settings.

Vinzent03 avatar Mar 20 '25 20:03 Vinzent03

Image

Image

It's not 1Passwords friendly. My understanding that the ssh-agent is fetching the keys from the 1password which it uses for signing.

richban avatar Mar 22 '25 20:03 richban

I'm not familiar with 1password and don't own a mac device, so I can't really test this. I'm sorry, but I don't know what's exactly wrong here and how to help you further.

Vinzent03 avatar Mar 22 '25 21:03 Vinzent03

No problem, I might revisit this problem when I got time. Thanks for your input.

richban avatar Mar 23 '25 10:03 richban

Unfortunately, I have a similar issue to this now also since setting up 1Password as my SSH Agent. Prior to doing this the Obsidian git plugin worked fine.

The relevant part of the console log (redacted) is:

Load key "/Users/user_name/.ssh/id_gitlab_xxxxx.pub": invalid format
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

It appears to me that the plugin is looking for a private key with 600 permissions and does not recognise that the 1Password SSH Agent relies on public keys (with permissions 644) in the ~/.ssh folder instead, which it uses to look up the associated private key in the secure 1Password vault.

I can confirm that interacting with the same git repo via iTerm or VS Code Terminal works normally, and am able to push, pull etc.

Hopefully the plugin can be made to work with SSH agents like 1Password, as it is much secure and manageable configuration.

grantx2016 avatar May 13 '25 03:05 grantx2016

The plugin doesn't really handle authentication itself, but delegates that completely to git. So I don't know why 1password is such a special case. The issue has to be some environment variable or similar.

Vinzent03 avatar May 22 '25 15:05 Vinzent03

I have tried adding the 1Password SSH agent socket to the git plugin settings along wth the PATH to the op binary (which was already set in my .zshrc file) but with no success. I get the same error message as I previously reported.

Image

Other than this, the git plugin appears to be working normally e.g. wth scheduled local commits successfully executed. I am still able to push to my remote repo without issue via VS Code.

grantx2016 avatar May 30 '25 04:05 grantx2016

Your PATH setting is wrong. Add only one path per line so it is only /opt/homebrew/bin without any export or PATH=

Vinzent03 avatar May 30 '25 09:05 Vinzent03

Your PATH setting is wrong. Add only one path per line so it is only /opt/homebrew/bin without any export or PATH=

Originally posted by @Vinzent03 in #876

Thanks for the clarification. I have tried both the following without success:

/opt/homebrew/bin

AND

/opt/homebrew/bin$PATH

I get the same error as previously:

"Pushing to ssh://xxxx.com.au:nnnn/redacted/redacted/obsidian/obsidian-vault.git Load key "/Users/redacted/.ssh/id_gitlab_river-gr.pub": invalid format [email protected]: Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists."

grantx2016 avatar Jun 09 '25 08:06 grantx2016

The plugin doesn't really handle authentication itself, but delegates that completely to git. So I don't know why 1password is such a special case. The issue has to be some environment variable or similar.

@Vinzent03, I had no issues using 1password ssh-agent along with obsidian-git. From my perspective the plugin works properly and those error are directly tied on ssh-agent misconfiguration to each use case.

@richban @grantx2016 try the references from 1password official documentation that could help on your end.

Also, I didn't need to specify any additional environment variable on obsidian interface.

gohorze avatar Jul 12 '25 20:07 gohorze

I have a setup similar to yours (macOS + ssh-agent) and I found the cause: the env isn’t set correctly for the git command (gitManager/simpleGit.ts simply runs git commands using process).

For some reason (I didn’t take time to dig deeper), two env variables need to be manually passed to git:

  • HOME -> so git can read the content of "$HOME/.gitconfig" which, in my case, contains the config needed for my ssh-agent

  • SSH_AUTH_SOCK -> so git can connect to the ssh-agent (1Password, or whatever)

(BTW, @grantx2016 you shouldn’t need to modify your PATH to add brew path because Obsidian and the git plugin don’t need access to the ⁠op binary.)

So the workaround is just to add these lines in the Settings->Git->Additional environment variables field:

HOME=/Users/<your-username>
SSH_AUTH_SOCK=<path-to-your-ssh-agent-sock>

⚠️ Be careful, don’t add any quotes around the value of the environment variable, or it won’t work. You just need unquoted paths, like in my example.

So to sum up, I feel there are two issues:

  • The env isn’t being passed correctly to the git command on macOS, whether because of Obsidian, the plugin, or something else.
  • If you put quotes around the value of an env variable in the settings, it doesn’t work. The issue probably comes from here and that the quotes are never interpreted (not tested): https://github.com/Vinzent03/obsidian-git/blob/180a314ca65bf666a8e15aaa07dc0d6b1e1ec838/src/gitManager/simpleGit.ts#L85-L88

aeddi avatar Sep 11 '25 14:09 aeddi

Thanks @aeddi. It worked. Just one difference though. For reasons I cannot understand it would not accept the HOME being defined separately so just had to use the explicit full path for SSH_AUTH_SOCK I.e. SSH_AUTH_SOCK=/Users/username/...

grantx2016 avatar Oct 06 '25 06:10 grantx2016

@aeddi Your suggestion worked for me (I'm on MacOS), thank you!
I had to click the "Reload with new environment variables" button to make it work, though.

Ken-vdE avatar Oct 17 '25 08:10 Ken-vdE