purcell / exec-path-from-shell

Make Emacs use the $PATH set up by the user's shell
Other
1.43k stars 82 forks source link

PATH declarations + exec-path-from-shell causes Tramp to hang #42

Closed incandescentman closed 4 years ago

incandescentman commented 8 years ago

I added two new lines to my .bashrc [so that Bash can find my Go programs][1]:

GOROOT=/Users/jay/work 
PATH=$PATH:$GOROOT/bin 

But as a result, when I launch Emacs, Emacs hangs for several minutes and I get this error:

Tramp: Opening connection for bin using ssh...
Tramp: Sending command `exec ssh   -o ControlMaster=auto -o ControlPath='tramp.%C' -o ControlPersist=no -e none bin'
Tramp: Waiting for prompts from remote shell...
Tramp failed to connect.  If this happens repeatedly, try
    `M-x tramp-cleanup-this-connection'
Tramp: Waiting for prompts from remote shell...failed
Tramp: Opening connection for bin using ssh...failed

Disabling exec-path-from-shell resolved the issue: http://emacs.stackexchange.com/questions/24159/tramp-waiting-for-prompts-from-remote-shell?noredirect=1#comment37054_24159

How do I resolve this error without disabling exec-path-from-shell?

purcell commented 8 years ago

Thanks. I’ve answered on the stackexchange post, but if there’s more to discuss, this issue would be the easier place to do it.

incandescentman commented 8 years ago

It looks like you've run the exec-path-from-shell from a Tramp buffer, so when it runs the shell, it attempts to do its magic on the remote server and then set the environment variables in your local emacs instance.

I don't think I've done that? At least not on purpose. I'm just trying to launch Emacs. Maybe I have an error in my .bashrc? Shall I share it with you?

purcell commented 8 years ago

Hmm. First thing I'd try would be to add a (message "...") call before and after calling exec-path-from-shell-initialize in your startup files. If there's an error, or it doesn't reach the second message call, then you know exec-path-from-shell is failing.

If there's no error, but the startup subsequently hangs, then the problem must be due to exec-path-from-shell's effect on the Emacs instance, which is (by default) to set the $PATH and $MANPATH environment variables. It's not inconceivable that your $PATH might then be set wrong due to your bash startup files, causing tramp to not find ssh or other programs it needs. So, in short, maybe try:

(message "Calling exec-path-from-shell-initialize")
(exec-path-from-shell-initialize)
(message "PATH is now: %s" (getenv "PATH"))

and see whether you get a reasonable-looking $PATH from the final statement there. If not, we can look at your .bashrc. :-)

P.S. Nice to meet you - I recall enjoying your writing previously.