windowsemacsensime

can't run emacs ensime on Windows


when I hit M-x and write 'ensime' I get an error

    `flet' is an obsolete macro (as of 24.3); use either `cl-flet' or `cl-letf'.
    'let: Wrong type argument: arrayp, nil'

When I had 'require ensime' in _emacs, it told me something more:

Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
file-truename(nil)
(let ((java (file-truename (executable-find "javac")))) (warn "JDK_HOME and JAVA_HOME are not       set, inferring from %s" java) (ensime--parent-dir (ensime--parent-dir java)))
 (cond ((getenv "JDK_HOME")) ((getenv "JAVA_HOME")) ((file-exists-p "/usr/libexec/java_home") (s-chomp (shell-command-to-string "/usr/libexec/java_home"))) ((quote t) (let ((java (file-truename      (executable-find "javac")))) (warn "JDK_HOME and JAVA_HOME are not set, inferring from %s" java)     (ensime--parent-dir (ensime--parent-dir java)))))
  eval((cond ((getenv "JDK_HOME")) ((getenv "JAVA_HOME")) ((file-exists-p "/usr/libexec/java_home") (s-chomp (shell-command-to-string "/usr/libexec/java_home"))) ((quote t) (let ((java (file-truename (executable-find "javac")))) (warn "JDK_HOME and JAVA_HOME are not set, inferring from %s" java) (ensime--parent-dir (ensime--parent-dir java))))))
 custom-initialize-reset(ensime-default-java-home (cond ((getenv "JDK_HOME")) ((getenv "JAVA_HOME")) ((file-exists-p "/usr/libexec/java_home") (s-chomp (shell-command-to-string "/usr/libexec/java_home"))) ((quote t) (let ((java (file-truename (executable-find "javac")))) (warn "JDK_HOME and JAVA_HOME are not set, inferring from %s" java) (ensime--parent-dir (ensime--parent-dir java))))))
  custom-declare-variable(ensime-default-java-home (cond ((getenv "JDK_HOME")) ((getenv "JAVA_HOME")) ((file-exists-p "/usr/libexec/java_home") (s-chomp (shell-command-to-string "/usr/libexec/java_home"))) ((quote t) (let ((java (file-truename (executable-find "javac")))) (warn "JDK_HOME and JAVA_HOME are not set, inferring from %s" java) (ensime--parent-dir (ensime--parent-dir java))))) "Location of the JDK's base directory" :type string :group ensime-server)
  eval-buffer(#<buffer  *load*-216581> nil "c:/Users/leokr_000/AppData/Roaming/.emacs.d/elpa/ensime-20141007.246/ensime-vars.el" nil t)  ; Reading at buffer position 2344
  load-with-code-conversion("c:/Users/leokr_000/AppData/Roaming/.emacs.d/elpa/ensime-20141007.246/ensime-vars.el" "c:/Users/leokr_000/AppData/Roaming/.emacs.d/elpa/ensime-20141007.246/ensime-vars.el" nil t)
 require(ensime-vars)
  eval-buffer(#<buffer  *load*-524611> nil "c:/Users/leokr_000/AppData/Roaming/.emacs.d/elpa/ensime-20141007.246/ensime.el" nil t)  ; Reading at buffer position 1766
  load-with-code-conversion("c:/Users/leokr_000/AppData/Roaming/.emacs.d/elpa/ensime-20141007.246/ensime.el" "c:/Users/leokr_000/AppData/Roaming/.emacs.d/elpa/ensime-20141007.246/ensime.el" nil t)
  require(ensime)
  eval-buffer(#<buffer  *load*> nil "c:/Users/leokr_000/AppData/Roaming/_emacs" nil t)  ; Reading at buffer position 220
  load-with-code-conversion("c:/Users/leokr_000/AppData/Roaming/_emacs"               "c:/Users/leokr_000/AppData/Roaming/_emacs" t t)
   load("~/_emacs" t t)
   #[0 "\205\262

This "_emacs" file was in fact copied from here https://github.com/ensime/ensime-server/wiki/Quick-Start-Guide I am running Windows 8 and emacs 24.3.


Solution

  • Apparently, Emas can't find your javac executable. Make sure you do have javac (or javac.exe maybe for your platform) somewhere and this this somewhere is listed in exec-path. Detailed explanation:

    Debugger entered--Lisp error: (wrong-type-argument arrayp nil)
    

    This says that the code tried to treat nil as if it were an array (a string is also an array).

    file-truename(nil)
    

    This says that it happened while calling file-truename with argument nil, and indeed, file-truename takes a file name (a string) as argument, so nil is not a valid argument for it.

    (let ((java (file-truename (executable-find "javac"))))
    

    This says that it happened while evaluating this code, where we see that the arg to file-truename is actually the value returned by (executable-find "javac") and this expression should return either the absolute file name of javac (as found in exec-path), or nil if it can't find it.