1

Flymake in emacs was properly working until update to Yosemite. But now it's complaining:

Flymake: Failed to launch syntax check process 'pychecker' with args (<filename>_flymake.py): Searching for program: no such file or directory, pychecker. Flymake will be switched OFF.

where <filename> is the name of the file in the opened buffer. Here's my flymake config:

(add-to-list 'load-path "~/.emacs.d/")
;; Setup for Flymake code checking.
(require 'flymake)
(load-library "flymake-cursor")

;; Script that flymake uses to check code. This script must be
;; present in the system path.
(setq pycodechecker "pychecker")

(when (load "flymake" t)
  (defun flymake-pycodecheck-init ()
    (let* ((temp-file (flymake-init-create-temp-buffer-copy
                       'flymake-create-temp-inplace))
           (local-file (file-relative-name
                        temp-file
                        (file-name-directory buffer-file-name))))
      (list pycodechecker (list local-file))))
  (add-to-list 'flymake-allowed-file-name-masks
               '("\\.py\\'" flymake-pycodecheck-init)))

(add-hook 'python-mode-hook 'flymake-mode)

here's /usr/local/bin/pychecker:

#! /bin/sh

pyflakes "$1"
pep8 --repeat "$1" --max-line-length=80 --ignore=E123,E133,E226,E501
true

here's $PATH:

/Users/<user>/Envs/<venv>/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/texbin

where <user> is my user name and <venv> is the currently active virtual-env.

pychecker works properly if run from the shell.

I start emacs from shell by typing emacsgui (alias emacsgui='open -a emacs'), usually with the venv activated. I also tried opening emacs without any venv activated but the problem still occur. What is the problem?

Kampai
  • 22,848
  • 21
  • 95
  • 95
se7entyse7en
  • 4,310
  • 7
  • 33
  • 50

1 Answers1

1

I solved by adding this to my .emacs file:

(defun set-exec-path-from-shell-PATH ()
  (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))))

(when (and window-system (eq system-type 'darwin))
  ;; When started from Emacs.app or similar, ensure $PATH
  ;; is the same the user would see in Terminal.app
  (set-exec-path-from-shell-PATH))
se7entyse7en
  • 4,310
  • 7
  • 33
  • 50