When launched at system start-up, the Emacs daemon doesn't pick up modifications to the PATH introduced by shell initialization scripts.

Emacswiki suggests to use this function to update Emacs' PATH,

(defun set-exec-path-from-shell-PATH ()
  "Set up Emacs' `exec-path' and PATH environment variable to match
that used by the user's shell.

This is particularly useful under Mac OS X and macOS, where GUI
apps are not started from a shell."
  (let ((path-from-shell (replace-regexp-in-string
              "[ \t\n]*$" "" (shell-command-to-string
                      "$SHELL --login -i -c 'echo $PATH'"
    (setenv "PATH" path-from-shell)
    (setq exec-path (split-string path-from-shell path-separator))))


but it returns some errors:

bash: cannot set terminal process group (-1): Inappropriate ioctl for device
bash: no job control in this shell
stty: 'standard input': Inappropriate ioctl for device

As far as I understand (my main reference), since I want to run Bash in interactive mode (so that it loads ~/.bashrc) I should use start-file-process(-shell-command) to invoke the shell process. However, I can't figure out how to store the output of the command in a string when I do so.

  • I fixed the doc in the Emacswiki and opened an issue on the source of the misinformation,
    – NickD
    Mar 24, 2021 at 3:45
  • Good Q and A. Thanks for fixing that wiki page, @NickD
    – Drew
    Mar 24, 2021 at 4:29
  • There is the package exec-path-from-shell - also see Aquamacs code for another way
    – mmmmmm
    Mar 24, 2021 at 10:52

1 Answer 1


No, you don’t want to use -i because you’re not launching an interactive shell. That is, this shell will not be connected to a terminal that the user can type in. It is instead going to be connected to a pipe so that Emacs can read whatever it prints. Removing the -i option will prevent Bash from trying to use inappropriate ioctls on the stdout and stdin, and thus eliminate the error messages.

If your PATH is only configured by your ~/.bashrc file, then you’ve misconfigured Bash. You should ensure that at least your PATH is set up consistently in both interactive and non—interactive shells. Most distros do this by making the default ~/.bash_profile source ~/.bashrc for you. Configuring this correctly will ensure that you get the correct PATH value.

  • how do I configure this correctly?
    – xdavidliu
    5 hours ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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