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

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?

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.

Related

file-error "https://melpa.org/packages/archive-contents" "Bad Request" during emacs 25.2 startup with Prelude initialization

New job, new emacs setup. I've used emacs for years but never did much customization. Running CentOS Linux 7.7 and emacs 25.2. I wanted to try the Prelude "starter kit" so I installed it. On emacs starup the Prelude init.el file (~/.emacs.d/init.el) runs and I see: error: Package ‘ag-’ is unavailable.
When I start emacs with debug enabled I see the following back trace:
Debugger entered--Lisp error: (file-error "https://melpa.org/packages/archive-contents" "Bad Request")
signal(file-error ("https://melpa.org/packages/archive-contents" "Bad Request"))
package--download-one-archive(("melpa" . "https://melpa.org/packages/") "archive-contents" nil)
package--download-and-read-archives(nil)
package-refresh-contents()
prelude-install-packages()
require(prelude-packages)
.
.
I'd appreciate any suggestions on how to resolve this.
I just ran into similar issues on a new Debian install, it looks like there are some setup issues in the default init.el.
Check your init.el against the [https://melpa.org/#/getting-started][1], it currently gives the default melpa link as: "https://melpa.org/packages/" - in my case it was http rather than https.
Then check that M-x package-list-packages works, go through the M-x package-refresh-contents , update cycle. For some reason this took a couple of attempts to work for me.

current session error opening REPL in emacs with CIDER

I've been following a tutorial and hit an error where there wasn't one in the book. I have reinstalled leinigen, updated java and reinstalled cider on emacs.
But doesn't seem to help and I can't find this error message online. Running M-x "cider-jack-in" to open a REPL gives me the error message:
"Symbol’s function definition is void: sesman-current-sessions"
and I can't figure out what's causing this, any help is gratefully received.
I ran into the same problem. It's possible that you're using an old version of the sesman package. Updating cider for me didn't update the sesman dependency.
For example, sesman-20180903.1826 doesn't define sesman-current-sessions while sesman-20181109.1100 does. Updating sesman fixed the issue for me.
Can you post your project.clj file? Maybe it contains old versions of libraries that are either conflicting with the newest CIDER.
A typical minimal project.clj from a fresh new project created with lein new app myapp will look like this:
(defproject myapp "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
:url "https://www.eclipse.org/legal/epl-2.0/"}
:dependencies [[org.clojure/clojure "1.9.0"]]
:main ^:skip-aot overflow.core
:target-path "target/%s"
:profiles {:uberjar {:aot :all}})

Ensime not typechecking correctly, nor is its autocomplete working

I wanted to try and see how good Ensime's type checking capabilities were, and while they seemed to work fine at first, it appears it keeps referencing bits of code that no longer exist: (larger version here)
It says it couldn't find the value asdfadsfasdf which was correct, back when I wrote it as random garbage to test the type checker; however it's not there anymore and Ensime keeps complaining about it, rather than spotting the missing : and wrong type name in the when function.
Add to that the fact that despite it having access to the Ensime server, it still won't run autocomplete..
Specs:
Emacs version: 24.3.1
Sbt version: 0.13.5
System: Mac OS X version 10.9.5 "Mavericks"
Excerpt from .emacs that relates to Ensime and Scala:
(require 'ensime)
(add-hook 'scala-mode-hook 'ensime-scala-mode-hook)
What do I do to get it working correctly?

Problems getting Emacs 24 to run SLIME and Clojure Debug Toolkit (CDT)

I'm trying to get Slime working with CDT and emacs 24, to no avail, and would appreciate suggestions.
1) I did get clojure-jack-in to run, but only when I loaded swank-clojure 1.3.3 as a lein plugin, as described in the github swank-clojure page, https://github.com/technomancy/swank-clojure.
2) I tried to get swank-clojure 1.4.0-SNAPSHOT loaded as described by George Jahad in http://georgejahad.com/clojure/swank-cdt.html (using Clojure 1.2.1), but I couldn't clojure-jack-in to run. I got the same error as described in 3), below.
3) Most recently, I tried duplicating the results of the short proof-of-concept video on the technomancy.us site, on the "in which radical simplification ensues," http://technomancy.us/149. In this method, I loaded swank-clojure 1.4.0-SNAPSHOT as a lein plugin and confirmed it was loaded to ~/.lein/plugins/swank-clojure-1.4.0-SNAPSHOT.jar. When I created a new lein project, did lein deps on it, opened the project's core.clj file in emacs, and then executed M-x clojure-jack-in, instead of getting a REPL, I got the following error in the emacs minibuffer:
error in process filter: Search failed: "(run-hooks 'slime-load-hook) ;
on port"
Note that the end of the error string does not include a port number. Unless that's an arbitrary truncation of a longer error string, the lack of a port number makes me uneasy.
The *swank* buffer is long, beginning with:
;;; Bootstrapping bundled version of SLIME; please wait...
and ending with:
(provide 'slime-repl)
;;; slime-repl.el ends here
(run-hooks 'slime-load-hook)
;;; proceed to jack in
which is consistent with the error message.
I've spent about six hours on this, including a lot of web searches, and no luck. Thanks for any help you can provide.
ADDENDUM: I've continued experimenting, and now the *swank* buffer ends like before (dying at the same place), but with additional lines at the end. FYI, here it is:
(provide 'slime-repl)
;;; slime-repl.el ends here
(run-hooks 'slime-load-hook)
[WARNING] Overriding profile: 'null' (source: pom) with new instance from source: pom
[WARNING] Overriding profile: 'null' (source: pom) with new instance from source: pom
[WARNING] Overriding profile: 'null' (source: pom) with new instance from source: pom
Downloading: org/clojure/clojure/1.+/clojure-1.+.pom from repository clojars at http://clojars.org/repo/
Unable to locate resource in repository
[INFO] Unable to find resource 'org.clojure:clojure:pom:1.+' in repository clojars (http://clojars.org/repo/)
Downloading: org/clojure/clojure/1.+/clojure-1.+.pom from repository stuartsierra-releases at http://stuartsierra.com/maven2
Unable to locate resource in repository
[INFO] Unable to find resource 'org.clojure:clojure:pom:1.+' in repository stuartsierra-releases (http://stuartsierra.com/maven2)
Downloading: org/clojure/clojure/1.+/clojure-1.+.pom from repository clojure at http://build.clojure.org/releases
Unable to locate resource in repository
[INFO] Unable to find resource 'org.clojure:clojure:pom:1.+' in repository clojure (http://build.clojure.org/releases)
Downloading: org/clojure/clojure/1.+/clojure-1.+.pom from repository clojure-snapshots at http://build.clojure.org/snapshots
Unable to locate resource in repository
[INFO] Unable to find resource 'org.clojure:clojure:pom:1.+' in repository clojure-snapshots (http://build.clojure.org/snapshots)
Downloading: org/clojure/clojure/1.+/clojure-1.+.pom from repository central at http://repo1.maven.org/maven2
Unable to locate resource in repository
[INFO] Unable to find resource 'org.clojure:clojure:pom:1.+' in repository central (http://repo1.maven.org/maven2)
Copying 9 files to /Users/gw/tech/clojurestuff/cljprojects/infwb/lib
Copying 1 file to /Users/gw/tech/clojurestuff/cljprojects/infwb/lib/dev
Listening for transport dt_socket at address: 61012
;;; proceed to jack in
(end of addendum)
ADDENDUM 2 (Dec. 12, 2011) Thanks to all who offered help, especially #ivant, to whom I'm awarding the "check mark." I'm going to consider this situation closed because I've given up trying to fix it. It was complicated by my use of a prepackaged initialization package that I'm sure is quite nice, but I couldn't understand what it was doing, nor whether it was contributing to the problem.
I restarted with a "clean" Emacs 24 and reverted to swank-clojure 1.3.3, and clojure-jack-in works just fine now. I'll try CDT later, once the bug logged to swank-clojure 1.4.0-SNAPSHOT is resolved.
I learned a few things from people's comments--thanks again.
N.B. I don't have neither emacs 24, nor CDT installed.
Looking at the code of clojure-jack-in, it looks like it chooses a port beforehand, and starts clojure using lein jack-in <port> (unless you redefined clojure-swank-command somewhere).
It then parses the output (which is visible in the *swank* buffer) looking for specific strings to trigger some actions. These are:
;;; Bootstrapping bundled version of SLIME
...
;;; Done bootstrapping.
or as a fallback:
;;; Bootstrapping bundled version of SLIME
...
(run-hooks 'slime-load-hook) ; on port
and it executes the emacs commands between these lines. The string "proceed to jack in" triggers the actual connect.
So check the source, check the values of some relevant variables (like clojure-swank-command) and check what's in the *swank* buffer for clues.
EDIT
You may want to run lein deps in your project, brfore trying M-x clojure-jack-in, otherwise output like
Downloading: org/clojure/clojure/1.+/clojure-1.+.pom from repository clojars at http://clojars.org/repo/
...
can end up in the *swank* buffer and can interfere with the starting process.
But this specific dependency looks quite suspicious to me. Can you post your project.clj file as well?
Upgrade to swank-clojure 1.4.0 (released yesterday) and everything will just work out of the box. lein plugin install swank-clojure 1.4.0
CDT installation and integration are now completely automated. Make sure to remove any old copies of swank-clojure, slime.el and slime-repl.el you have lying around. Just to be safe, also make sure you've got the latest clojure-mode.el installed.
I don't have an answer, although I've hit this same problem, but I can provide a work around.
Just run lein swank from the commandline and use slime-connect inside Emacs, and you'll at least have a working environment again.
This has also been filed on the swank-clojure bug list:
https://github.com/technomancy/swank-clojure/issues/87

How to use clojure doc function?

I'm just starting with Clojure and can't access to the doc function.
I'm using clojure 1.3 with emacs24 and swank-clojure.
user> *clojure-version*
{:major 1, :minor 3, :incremental 0, :qualifier nil}
But when I try:
(doc doc)
I get:
Unable to resolve symbol: doc in this context
[Thrown class java.lang.RuntimeException]
I've read Why does REPL treat clojure.core/doc as a var? and as suggested:
(clojure.repl/doc doc)
But then, I receive:
clojure.repl
[Thrown class java.lang.ClassNotFoundException]
It seems I am not "importing" the usual namespaces, but really doesn't know how to do it.
Thanks.
UPDATE
Using clojure from java (java -jar ...) it works well, so it's a problem with the emacs setup.
You need to grab the clojure.repl namespace one way or another:
From the REPL
user> (use 'clojure.repl)
user> (doc doc)
or in your program
(ns foobar
(:use [clojure.repl]))
Add the following to your Leiningen user.clj file (on Mac / Linux, it's ~/.lein/user.clj):
;; ~/.lein/user.clj
(if (>= (.compareTo (clojure-version) "1.3.0") 0)
(do (use 'clojure.repl)
(use 'clojure.java.javadoc)))
This will cause Leiningen to automatically import those two namespaces at startup for projects using Clojure 1.3.0 and later (but not for projects using Clojure 1.2.1 or earlier - where doc and source were always available).
Credit goes to Matthew Boston for this. Note also Phil Hagelberg's reply which points out most of the REPL-specific functionality is accessible directly in Emacs / Slime without needing the functions directly in the REPL.
As of Lein 2, namespaces can be automatically imported at startup using :injections, e.g:
;; ~/.lein/profiles.clj
{:user {:plugins [[lein-swank "1.4.4"]
[lein-noir "1.2.1"]
[lein-pprint "1.1.1"]]
:injections [(use 'clojure.repl)
(use 'clojure.java.javadoc)
(use 'clojure.pprint)] }}
But see other responses for SLIME equivalents.
I'm unsure of when this became the case, but as of lein 2.2 doc is available at the repl by default.