emacshlint

Hlint integration with emacs not working on new machine


I use hlint from within emacs with hs-lint.el in exactly the manner described in the link.

hlint lives in my ~/.cabal/bin directory, which is on my $PATH, and everything works as expected when I call it from the command line. When I set this up on a new machine and tried to invoke it within emacs, however, I get the following message in the minibuffer:

error in process sentinel: Moved past last error

and the following in an *hs-lint* buffer:

-*- mode: hs-lint; default-directory: "/home/wvoq/project/" -*-
HLint started at Fri Jan 13 02:48:53

hlint /home/wvoq/project/myfile.hs
/bin/bash: hlint: command not found

HLint exited abnormally with code 127 at Fri Jan 13 02:48:53

From my understanding, there's no reason that bash should have trouble finding hlint. Is there?

Thanks in advance for any suggestions.


Solution

  • If you launch Emacs from a desktop shortcut the PATH that it has is not the PATH that your shell has. If you launch Emacs from a shell you should be able to confirm that this is the problem. There are many ways to fix it. For example, on OS X you can add environment variables to ~/.MacOSX/environment.plist. Or you can set PATH inside Emacs with something like:

    (setenv "PATH" (concat "~/.cabal/bin:" (getenv "PATH")))
    (add-to-list 'exec-path "~/.cabal/bin")