Emacs: Tramp doesn't work

Viewed 20926

I tried to open a remote file via Emacs via Tramp.

(require 'tramp)
(setq tramp-default-method "ssh")

I get a message from Emacs

Tramp: Waiting for prompts from remote shell

Emacs hung and did not respond to any action after that

Emacs was installed on Windows; the remote file was on a Linux machine.

6 Answers

Well, this is a defect of tramp.

The real solution is to prevent loading .bashrc when tramp is used. (because now it is PS1, but it can be PATH, or any other thing that your .bashrc will do that will displease tramp...).

This can be done by asking ssh to set an environment variable, and testing it in .bashrc:

Add this to ~/.emacs:

(require 'tramp-sh nil t) (setf tramp-ssh-controlmaster-options (concat "-o SendEnv TRAMP=yes " tramp-ssh-controlmaster-options))

and that at the beginning of ~/.bashrc:

if [ ! -z ${TRAMP-x} ] ; then return fi

Another default of tramp is that it doesn't have a variable to pass random arguments to the ssh command, we have to piggy-back on tramp-ssh-controlmaster-options.

If the problem is your fancy custom prompt in the remote shell, an easy workaround is to add to your .bashrc or equivalent:

if [[ $TERM == "dumb" ]]; then
    export PS1="$ "
fi

After you define your PS1.

Note: the credit goes to ChasingLogic as this is their suggestion in this thread.

Related