5

Trying to launch an inferior shell (M-x shell) in Emacs on Windows that connects to MSYS2.

I found this snippet from Mastering Emacs - Running Shells in Emacs Mastering Emacs, and adapted it:

(setq explicit-shell-file-name "D:/msys64/usr/bin/bash.exe")
(setq shell-file-name "bash")
(setq explicit-bash.exe-args '("--login" "-i")) <- Have also tried -c, and without "--login"
(setenv "SHELL" shell-file-name)
(add-hook 'comint-output-filter-functions 'comint-strip-ctrl-m)

I get the following:

bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
]0;~
me@computer MSYS ~
$ 

So I have some extra goofy characters and an inappropriate command passed to the MSYS shell, but this is progress! MSYS2 + Emacs on Windows would be AMAZING.

trayres
  • 522
  • 2
  • 6
  • 18
  • 1
    An *inferior* shell, you say? You must be looking for `csh` (pax ducks for cover). – paxdiablo Aug 07 '17 at 06:33
  • 1
    Are you sure that `D:/msys64/mingw64/bin/bash.exe` is the correct path? I think a non-existent executable is the most likely reason for getting the error you are seeing. – D Krueger Aug 09 '17 at 00:06
  • @DKrueger You're right! I now have Emacs talking through MSYS, but not quite 'cleanly'. It was in D:/msys64/usr/bin. Feeeeeeeling stupid on this one. – trayres Aug 11 '17 at 04:46

1 Answers1

1

The problem is -i for Bash. It means interactive, so Bash attempts to configure terminal with ioctl which is nonsense for native Windows Emacs. Strip -i in native Emacs when you are using MSYS2 Bash.

gavenkoa
  • 45,285
  • 19
  • 251
  • 303
  • 1
    5 years later. This is why Emacs will win, in the end, over all other editors. – trayres Dec 15 '22 at 00:09
  • It seems we need to suffer from error message that is triggered by `-i` because the option is responsible for activating interactive mode: thus loading of `~/.bashrc`! – gavenkoa Dec 15 '22 at 13:13