Skip to content
Jack Henahan edited this page May 4, 2015 · 2 revisions

Sometimes you will have PATH problems with Emacs. This page tries to address that with some approaches.

Possibly Emacs doesn't start with the right PATH variable. I always start it from the terminal, but from the GNOME menu shortcut, it's just, blank. To check this is indeed the cause, check out:

M-: (getenv "PATH")

If it's different to your echo $PATH in your shell then it's probably that. I think this is because Emacs is not started from the shell. So you need to add .cabal/bin and your GHC path to your session-wide (or system-wide) environment variable file: https://help.ubuntu.com/community/EnvironmentVariables#Session-wide_environment_variables

Or you can make a bash script to run Emacs and change your Emacs launching shortcut to run that instead.

Another approach (helpful when running Emacs as a daemon) is to set the PATH inside Emacs by adding something like this to your ~/.emacs:

(setenv "PATH"
  (concat
   (getenv "HOME") "/bin" ":"
   (getenv "HOME") "/.cabal/bin" ":"
   (getenv "PATH")
  )
)

Or if you have ~/.cabal/bin in your shell's PATH variable, try using the exec-path-from-shell package (available on Melpa); if you install it via Emacs' package interface you can just add (exec-path-from-shell-initialize) to your ~/.emacs (otherwise you'll also need to load the package).