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

Using 'ssh for straight-vc-git-default-protocol raises an odd error #449

Closed
ndw opened this issue Dec 27, 2019 · 7 comments
Closed

Using 'ssh for straight-vc-git-default-protocol raises an odd error #449

ndw opened this issue Dec 27, 2019 · 7 comments

Comments

@ndw
Copy link

ndw commented Dec 27, 2019

I don't believe this is actually an error in straight.el but I encountered it as a consequence so I'm wondering if you've already seen the answer. Feel free to simply close this without comment if the answer isn't obvious.

Per our earlier discussion (#441), I switched to using ssh as the default protocol for git. That allowed me to get packages from my non-github private repo.

In the course of exploring a broader re-write of my Emacs init file (what else are holidays for?), I had occasion to "start over" in a clean home directory. During the bootstrap process, straight.el comes to a github repo it wants to clone and falls over.

Cloning into '/Users/ndw/testhome/.emacs.d/straight/repos/git-timemachine'...
ssh_askpass: exec(/usr/X11R6/bin/ssh-askpass): No such file or directory
Host key verification failed.
fatal: Could not read from remote repository.

I'm running on MacOS and there's no /usr/X11R6/bin/ssh-askpass in sight. There is /usr/local/bin/pinentry-mac which I imagine would do the trick. So I go looking for where the X11R6 reference occurs. I expect to find a variable I can set to the correct pinentry program and all will be well.

  1. It's not in straight.el
  2. It's not under ~/.emacs.d
  3. It's not AFAICT in any of the lisp files in /Applications/Emacs.app/Contents/Resources/lisp (and yes, I did unzip them before grepping 😄 )
  4. And just FYI, I did start Emacs from the command line and the environment does seem to have the ssh-agent settings, but apparently it still wanted to ask.

I nudged the system to make sure it hadn't simply timed out, but no, ssh and friends were happy to go along with the agent values without asking me to refresh my password.

The workaround was simply to change the default protocol back to https, run the initial bootstrap, and then change it back to ssh. That'll be fine until the next time it tries to clone a new package, I guess, but hopefully I'll remember what to do.

Anyway, I'm just wondering if my ignorance is showing?

@ndw ndw added the support label Dec 27, 2019
@raxod502
Copy link
Member

See #334. You should be able to work around the problem more easily by configuring ssh-agent and then running ssh-add in a terminal to get your passphrase cached. I've tried a couple of times to solve the issue, but I keep running into weirdness and race conditions in trying to handle process filters synchronously.

@raxod502
Copy link
Member

Alternatively, I believe you should be able to install an ssh-askpass program and it will prompt you graphically. The problem is that straight.el doesn't currently know how to attach a tty to the processes it starts, like Magit does.

@ndw
Copy link
Author

ndw commented Dec 28, 2019

I have ssh-agent running and point 4 in my initial report was an attempt to demonstrate that I've started Emacs with an environment that includes the relevant environment variables. I can see if the brew version of ssh-askpass will work graphically.

(Nope. Maybe if I could change /usr/X11R6/bin/... somewhere...)

@raxod502
Copy link
Member

On Linux, I can install an ssh-askpass program and then export the SSH_ASKPASS variable to point at the full path of the executable, and then I get prompted graphically. That said, the usual way to work around this problem is by configuring ssh-agent correctly. I do not know what might be going wrong for it on your system. If you have the agent working from the command line, I assume you have AddKeysToAgent yes in your ~/.ssh/config already. Do the relevant variables show up from inside of Emacs using M-x getenv?

SSH_AGENT_PID=1354
SSH_AUTH_SOCK=/tmp/ssh-YfpfmKRyaOOj/agent.1352

Perhaps you have some package like exec-path-from-shell which is messing with your environment. Alternatively, sometimes upgrades and such can mess up the agent state, in which case restarting might help. You could also check to see what arguments ssh-agent is being started with. Maybe it's something you don't expect. I personally use ssh-agent -t 86400 in my shell init.

@ndw
Copy link
Author

ndw commented Dec 29, 2019

Ok. Thanks for the suggestions; it's clearly not a straight.el problem, but I appreciate the advice.

@ndw ndw closed this as completed Dec 29, 2019
@raxod502
Copy link
Member

Well, it definitely is a straight.el problem in the sense that #334 needs to be solved, but yeah the environmental stuff I can't do much about here.

@ndw
Copy link
Author

ndw commented Jan 8, 2020

FYI: I found an easy workaround. If I add a new package, I start emacs in a shell without a window manager:

/Applications/Emacs.app/Contents/MacOS/Emacs -nw

And then it uses ssh-agent and ssh works fine. I don't know why -nw is different in this case, but it is.

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

No branches or pull requests

2 participants