obsidian-git
obsidian-git copied to clipboard
[1Password, ssh-agent] Error: cannot run op: No such file or directory
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
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.
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.
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.
It's not 1Passwords friendly. My understanding that the ssh-agent is fetching the keys from the 1password which it uses for signing.
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.
No problem, I might revisit this problem when I got time. Thanks for your input.
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.
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.
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.
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.
Your PATH setting is wrong. Add only one path per line so it is only /opt/homebrew/bin without any export or PATH=
Your PATH setting is wrong. Add only one path per line so it is only
/opt/homebrew/binwithout 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."
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.
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-agentSSH_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
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/...
@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.