In Emacs, when I open the file /ssh:USER@HOST:/PATH
, Tramp mode kicks in and everything is great. While editing the file, I want to open a remote shell as well using M-x shell
, but its behaviour is just baffling. It seems to recognize I'm in Tramp mode (based on default-directory
, I think), and it presents this prompt in the minibuffer:
Remote shell path: /ssh:USER@HOST:PATH//usr/local/bin/bash
^
\-- Cursor here
The cursor is in the middle there, with the left part in grey and the right part in black. The right part is my local login shell. Now, if I press enter, it doesn't work. The buffer just has:
env: ‘/usr/local/bin/bash’: No such file or directory
The *Messages*
seem to indicate nothing went wrong with the Tramp connection:
Tramp: Opening connection for USER@HOST using ssh...
Tramp: Sending command ‘exec ssh -q -l USER -o ControlMaster=auto -o ControlPath='tramp.%C' -o ControlPersist=no -e none HOST’
Tramp: Waiting for prompts from remote shell...done
Tramp: Found remote shell prompt on ‘HOST’
Tramp: Opening connection for USER@HOST using ssh...done
I think I know what's happening. It's trying to run /usr/local/bin/bash on the remote server as the shell (which doesn't exist). If I manually change it to /ssh:USER@HOST:PATH/bin/bash
, it works and I get a remote shell as I expect. Note that I have to remove the double slash, and I have to keep the ssh part; /ssh:USER@HOST:PATH//bin/bash
doesn't work, nor does /bin/bash
.
My question is, WHY does Emacs assume the remote machine has the same shell at the same path? Why can't it just use the login shell of my user on that machine, which is what I'd assume people want 99% of the time? Is there any configuration to fix this?
Some details about my environment:
- macOS 10.12.6
- emacs build (Homebrew):
d12frosted/emacs-plus/emacs-plus: stable 25.3 (bottled), HEAD
- using
emacs -q
, so no config - my login shell on the local machine is
/usr/local/bin/bash