5

If I do:

  (getenv "PATH")

I get a list of colon-separated directories, including:

  /Users/michaeln/Library/Haskell/bin

If I look at the exec-path variable, I see a list including the same directory. If I do:

  (shell-command "echo $PATH")

I get a list of colon-separated directories including the same Haskell/bin directory as above. There is an executable pandoc in that directory. And yet, if I do:

  (shell-command "pandoc")

I get in response:

  /bin/bash: pandoc: command not found

What am I doing wrong?

  • Try adding the path of the folder where pandoc is located to your exec-path: emacswiki.org/emacs/ExecPath – lawlist Apr 8 '15 at 5:46
  • are you able to run pandoc from bash shell prompt? – Madhavan Apr 8 '15 at 5:53
  • @lawlist I have; as above "If I look at the exec-path variable...". – Michael Norrish Apr 8 '15 at 5:57
  • @MadhavanKumar Yes. If I run M-x shell and type pandoc --version, or if I run my usual shell within Terminal.app. – Michael Norrish Apr 8 '15 at 5:58
  • exec-path is only relevant to binaries Emacs wants to run. In this instance Emacs is running a shell (and the shell is running pandoc), so I believe there's no particular reason in this case for pandoc to be accessible from exec-path. – phils Apr 8 '15 at 7:35
5

If you are adding your Haskell bin to your PATH in a .bashrc or similar dotfile, this file only gets loaded when running an "interactive" shell. This happens when running M-x shell but not when running M-! / (shell-command), as there is no prompt. You can adjust the option flags that are sent to (shell-command) by adjusting shell-command-switch to instruct it to act interactively and load your shell dotfile with:

(setq shell-command-switch "-ic")
  • Curiously, something about my non-interactive bash setup must be setting my PATH rather than extending it: otherwise, surely the non-interactive shell would inherit the PATH variable that emacs has in its own environment. – Michael Norrish Apr 10 '15 at 3:37
  • Now, without changing any of my config files, I can't even reproduce the behaviour. I have rebooted the relevant machine because it just upgraded OS X version. I think the comment about interactive vs non-interactive shells is still very valuable though. Thanks! – Michael Norrish Apr 10 '15 at 3:44

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.