0

I have recently switched from launching Emacs from the terminal (i.e. emacs --init-directory "path/to/my/init") to launching it from a universal keybinding (i.e. super-e). This has had the unintended side-effect of making Magit essentially unusable, because it is no longer 'inheriting' the state of my ssh-agent. It used to be that if I was getting Permission denied (publickey) errors, it was a matter of a closing Emacs, ensuring my agent was running and the right keys were added to it, then relaunching Emacs from that terminal session.

However, when I launch it from the keybinding, I'm not able to get it to recognize ssh-agent state. That it can't pick this up from a terminal session that had nothing to do with its launch isn't too surprising, but I thought that running ssh-agent from within a term window might address the problem. No such luck.

I suppose that daemonizing the ssh-agent setup would get around this problem, but I'm unsure if I want to go that route. What options are available to me for configuring this within Emacs?

1 Answer 1

0

Well you've identified the issue: You're not starting Emacs in an environment which knows about your ssh-agent, so the most obvious solution is to remedy that.

Either start an agent as part of your desktop session, or else use a command or wrapper script which exports those environment variables for starting Emacs.

Keychain can help:

You can also just C-hf setenv the environment variables in Emacs. If your shell will have the environment, then you can tell Emacs to run a shell command to obtain the values. If you go that route, you might like https://github.com/purcell/exec-path-from-shell

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.