Search code examples
emacsclojurecider

"Not an nREPL dict" using cider-auto-test-mode


I am trying to run my namespace tests in Emacs/CIDER using CIDER's cider-auto-test-mode. Whenever I load the namespace, however, I get the error Not an nREPL dict. Any suggestions on how to resolve this or further debug it?

Before describing what I have found so far: I am using CIDER 0.12.0, cider-nrepl version 0.10.0, and nREPL 0.2.12. I know that the CIDER/cider-nrepl version discrepancy is not good; it is not by choice but I could get it fixed if it is the cause of this problem.

This same error message was discussed on a CIDER Github issue, and a follow-up humane-test-output issue. I haven't found anything in the build process I am using that might implicate humane-test-output.

The first time I load the file (C-c C-k), the tests run and I get the following stack trace:

error("Not an nREPL dict")
nrepl-dict-map( #[...]  ((dict "context" "my `testing` comment" ...)))
nrepl-dict-map( #[...] (dict "my-deftest-name" ((dict "context" "my `testing` comment" ...))))
cider-test-highlight-problems((dict "my-deftest-name" ((dict "context" "my `testing` comment" ...))))
nrepl--dispatch-response(...)

When I toggle-debug-on-error after having already loaded the file, the tests do not run again and I get this stack trace:

error("Not an nREPL dict")
nrepl-dict-keys(((dict "context" "my `testing` comment" ...)))
nrepl-dict-map(#[...] (dict "my-deftest-name" ((dict "context" "my `testing` comment" ...))
cider-test-clear-highlights()
cider-test-execute(...)
cider-test-run-ns-tests(...)
cider--test-silently()

Slightly different stack traces but same problem: A list of dict lists is not a valid nREPL dict. While cider-test-highlight-problems clearly expects and is getting a namespace and vars in the outer dict list, instead of receiving a dict list of dict lists as apparently expected, it instead receives a simple list of dict lists as shown in my stack traces.

Any suggestions of how I could further research or resolve this?


Solution

  • The first thing to check is the CIDER vs cider-nrepl version difference.

    It used to be the case that you had to put cider-nrepl into your ~/.lein/profile.clj's dependency section and fiddle with the versions until that error went away.

    You no longer need to do this, and it causes lots of problems with symptoms like this. These days cider provides it's own dependencies when you run cider-jack-in so the most common solution is to remove cider from your lein profile and let it choose the correct cider-nrepl version automatically.

    This may not be the problem here, though it's a good thing to resolve for at least anyone who comes along and finds similar symptoms later.