Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Ensime fails to start because 'sps' is void #162

mperlick opened this Issue · 11 comments

7 participants


On: Linux ripley 2.6.32-31-generic #61-Ubuntu SMP Fri Apr 8 18:25:51 UTC 2011 x86_64 GNU/Linux
with emacs: GNU Emacs 23.1.1 (x86_64-pc-linux-gnu, GTK+ Version 2.20.1) of 2011-03-04 on allspice, modified by Debian

ensime 0.5.0 wont start, becaus emacs pretends a variable called 'sps' to be void. When I change 'ensime-config.el':341+ to the code below it works:

(defun ensime-config-maybe-set-active-sbt-subproject (config)
  "If the sbt-subprojects key exists in the config, prompt the
 user for the desired subproject, and add an sbt-active-subproject
 value to the config."
;  (when-let (sps (plist-get config :sbt-subprojects))
  (let ((sps (plist-get config :sbt-subprojects)))
    (if sps
    ;; For testing purposes..
    (if ensime-prefer-noninteractive
         config :sbt-active-subproject
         (plist-get (car sps) :name))

      ;; Otherwise prompt the user
      (let* ((options
           (lambda (sp)
             (let ((nm (plist-get sp :name)))
               `(,nm . ,nm)))  sps))
         (keys (mapcar (lambda (opt) (car opt)) options)))
        (let ((key (when keys
              (concat "Which sbt subproject? ("
                  (mapconcat #'identity keys ", ")
                  "): ")
              keys nil t (car keys)))))
          (when-let (chosen (cdr (assoc key options)))
            (ensime-set-key config :sbt-active-subproject chosen)

I think this happens because of the circular dependency of ensime.el and ensime-config.el.

  • ensime.el defines the macro `when-let'
  • ensime.el requires 'ensime-config before the macro is defined
  • ensime-config.el uses the `when-let' macro defined in ensime.el

This problem occurrs when you're compiling the files in the wrong order and then loading the byte compiled files. Or when not having loaded the files before compiling, I think.

@aemmoncannon: could you refactor those bits'n'pieces required by several sub-modules in a single sub-module, ie. ensime-macros.el ?

I have a similar problem in ensime.el which leads to a "invalid-function ensime-with-connection-buffer" error when trying to enable ensime because that macro is used before it is defined.

To be fair, I should mention that I'm using byte-code-cache mode which auto-compiles .el files to .elc files in a different directory.


Since I don't byte-compile, I never hit this. But yes, it's a good idea to refactor so that byte-compilation works error-free.


I was able to bytecompile whole elisp directory.

  • Emacs 24.1
  • Brunch: Master

Here is what I did:
1. sbt stage
2. Put elisp directory on load-path
3. Restart emacs or eval new load-path
4. Fire C-u 0 M-x byte-recompile-directory
5. Select elisp directory
6. RET
Result: lots of warnings, 19 files compiled, 0 failed.

So I don't think this bug is still relevant.


@ancane: The problem is not byte-compiling, the problem is loading byte compiled files.


@tstgrub: After I byte-compile elisp directory, ensime starts and works fine pointed on it's own project. I can type-check, import, refactor ... I can't find any errors that you specified in this issue.
How do you load these files ?


To begin with, ensime-builder.el does not compile for me:

ensime-builder.el:23:1:Error: No setf-method known for ensime-builder-changed-files

But that's probably a different story.

When I do this (using Emacs GNU Emacs (i386-mingw-nt6.1.7601), git HEAD as of now):

  1. sbt stage
  2. emacs -Q
  3. (push "DIR" load-path)
  4. C-u 0 M-x byte-recompile-directory RET DIR RET
  5. exit emacs
  6. sbt "ensime generate" in ensime root dir
  7. emacs -Q
  8. M-: (push "DIR" load-path) RET
  9. M-x load-library RET ensime RET
  10. C-x C-f some-ensime-file.scala
  11. M-x ensime RET

I receive:

ensime-config-maybe-set-active-subproject: Symbol's function definition is void: sps

Unsurprisingly, since the code did not change, this bug is still alive.

As I said, it may depend on the byte compilation order. It probably just worked out for you by sheer luck...


The problem with sps will manifest if you compile ensime-config.el without having loaded ensime.el. An easy way to generate byte-compiled files that reproduce this is running (from the elisp directory) emacs -batch -L . -f batch-byte-compile *.el. Byte-compiling from an Emacs that's already loaded ensime might be a sufficient workaround.


Has a fix been found for this bug? I'm hitting it too...

@fommil fommil added this to the Backlog milestone

@tstgruby thanks! Can you please package this as a pull request against master?

I'm moving this to the next release milestone since we seem close to a solution.

@fommil fommil modified the milestone:, Backlog

when I tried to apply this patch, all the hunks failed. It looks like a version has been applied already.

If you still have problems, please open a new ticket... or better yet a pull request ;-)

@fommil fommil closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.