When I start up my current project with lein ring server and try to connect to it from Emacs via cider, I get the following warning:
; CIDER 0.8.2 (Java 1.7.0_51, Clojure 1.6.0, nREPL 0.2.6)
WARNING: The following required nREPL ops are not supported:
apropos classpath complete eldoc info inspect-start inspect-refresh inspect-pop inspect-push inspect-reset macroexpand ns-list ns-vars resource stacktrace toggle-trace-var toggle-trace-ns undef
Please, install (or update) cider-nrepl 0.8.2 and restart CIDER
user>
However, I do have a dependency for [cider/cider-nrepl "0.8.2"] in my project.clj. This is working just fine when I run lein repl and to which I can then connect just fine from cider:
; CIDER 0.8.2 (Java 1.7.0_51, Clojure 1.6.0, nREPL 0.2.6)
swedishchef.handler>
I can see that I get two different messages from leiningen wrt. nREPL, depending on how I start:
[sugarcube->swedishchef]lein ring server
See https://github.com/technomancy/leiningen/wiki/Repeatability)
Started nREPL server on port 44231
This is the output with the working cider-nrepl connection:
[sugarcube->swedishchef]lein repl
See https://github.com/technomancy/leiningen/wiki/Repeatability)
nREPL server started on port 38024 on host 127.0.0.1 - nrepl://127.0.0.1:38024
REPL-y 0.3.5, nREPL 0.2.6
Looking at the output of lein deps :tree I don't see any problems. So, my first question is whether this supposed to work, i.e., if cider-nrepl should override lein rings behavior wrt. to nrepl startup? If so, could somebody give some advice for further troubleshooting?
Use latest lein-ring plugin version 0.9.2 and add :nrepl-middleware containing vector of nrepl-middlewares to :repl-options in your project.clj
For example, I create the project by lein new compojure-app my-app. Then, I tested it by creating a empty leiningen profile in ~/.lein/profiles.clj ex. {:yolo {}} and starting ring server by lein with-profile yolo,dev ring server.
(defproject my-app "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:dependencies [[org.clojure/clojure "1.6.0"]
[compojure "1.1.6"]
[hiccup "1.0.5"]
[ring-server "0.3.1"]
[cider/cider-nrepl "0.8.2"]]
:plugins [[lein-ring "0.9.2"]]
:ring {:handler my-app.handler/app
:init my-app.handler/init
:destroy my-app.handler/destroy
:nrepl {:start? true}}
:repl-options {:nrepl-middleware
[cider.nrepl.middleware.apropos/wrap-apropos
cider.nrepl.middleware.classpath/wrap-classpath
cider.nrepl.middleware.complete/wrap-complete
cider.nrepl.middleware.info/wrap-info
cider.nrepl.middleware.inspect/wrap-inspect
cider.nrepl.middleware.macroexpand/wrap-macroexpand
cider.nrepl.middleware.ns/wrap-ns
cider.nrepl.middleware.resource/wrap-resource
cider.nrepl.middleware.stacktrace/wrap-stacktrace
cider.nrepl.middleware.test/wrap-test
cider.nrepl.middleware.trace/wrap-trace
cider.nrepl.middleware.undef/wrap-undef]}
:profiles
{:uberjar {:aot :all}
:production
{:ring
{:open-browser? false, :stacktraces? false, :auto-reload? false}}
:dev
{:dependencies [[ring-mock "0.1.5"] [ring/ring-devel "1.3.1"]]}})
Related
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}})
I'm currently working through the Midje tutorial:
https://github.com/marick/Midje/wiki/A-tutorial-introduction
I load the repl using cider-jack-in and can successfully run (autotest) which runs the tests.
However, when I change either the source or test files (and save them), the repl doesn't trigger a reload of the files and re-run the tests.
The reload works fine if I run the REPL from the command line.
I'm running Cider 0.8.1 nREPL 0.2.6 Clojure 1.4.0 on Windows 7.
Has anyone else had a problem with getting the REPL in Cider to work correctly with autotest and get it to rerun the tests when the source/test files are changed?
I had the same problem and solved it by updating the midje and lein-midje versions:
.lein/profiles.clj
{
:user {:plugins [[lein-midje "3.2"]]}
:repl {:plugins [
[refactor-nrepl "2.0.0"]
[cider/cider-nrepl "0.10.2"]
]}
}
project.clj:
(defproject cjtest "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:dependencies [[org.clojure/clojure "1.7.0"]]
:profiles {:dev {:dependencies [[midje "1.6.3"]]}})
I'm facing the same issue that is mentioned in the last comment in https://stackoverflow.com/a/25401281/4329629 (by Yu Shen)
I don't know why adding :plugins [[cider/cider-nrepl "0.7.0"]] at
~/.lein/profiles.clj does not work. But the same expression: :plugins
[[cider/cider-nrepl "0.7.0"]] at the project.clj of my project worked
as expected.
Till now i thought that all my projects were behaving this way, but today i found something different. Maybe a hint to what is going wrong? The 2 projects that behave differently have the following structure:
==================== project-1/project.clj (cider does not work) ====================
(defproject clj "0.1.0-SNAPSHOT"
:description "Frontend for stox#gryffin"
:url "http://stox.gryff.in/"
:dependencies [[selmer "0.6.9"]
[clj-time "0.6.0"]
[http-kit "2.1.18"]
[com.taoensso/timbre "3.2.1"]
[noir-exception "0.2.2"]
[im.chit/cronj "1.4.3"]
[environ "1.0.0"]
[org.clojure/tools.nrepl "0.2.3"]
[clojure-complete "0.2.4"]
[org.clojure/clojure "1.6.0"]
[org.clojure/data.json "0.2.5"]
[ring-server "0.3.1"]
[com.taoensso/tower "2.0.2"]
[com.novemberain/monger "2.0.0"]
[org.clojure/math.numeric-tower "0.0.4"]
[lib-noir "0.8.4"]]
:jvm-opts ["-Xmx512m" "-Xms128m"]
:plugins [[lein-environ "1.0.0"]]
:main clj.core)
==================== project-2/project.clj (cider works) ====================
(defproject project-euler "0.1.0-SNAPSHOT"
:description "Solve problems on project-euler website"
:url "http://projecteuler.net/problems"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.6.0"]
[org.clojure/core.memoize "0.5.6"]
[expectations "2.0.13"]
[org.clojure/math.numeric-tower "0.0.4"]
[org.clojure/math.combinatorics "0.0.8"]
[criterium "0.4.3"]
[org.clojure/tools.trace "0.7.8"]
[com.taoensso/timbre "3.2.1"]]
:plugins [[lein-autoexpect "1.0"]])
==================== ~/.lein/profiles.clj ====================
{:user {:plugins [[cider/cider-nrepl "0.9.0-SNAPSHOT"]]}}
EDIT:
1. error message seen in cider for project-1
; CIDER 0.9.0alpha (package: 20150114.512) (Java 1.7.0_55, Clojure 1.6.0, nREPL 0.2.6)
WARNING: The following required nREPL ops are not supported:
apropos classpath complete eldoc info inspect-start inspect-refresh inspect-pop inspect-push inspect-reset macroexpand ns-list ns-vars resource stacktrace toggle-trace-var toggle-trace-ns undef
Please, install (or update) cider-nrepl 0.9.0-SNAPSHOT and restart CIDER
WARNING: CIDER's version (0.9.0-snapshot) does not match cider-nrepl's version (not installed)
(snipped) lein deps :tree
warn
[cider/cider-nrepl "0.9.0-20150118.121230-2"]
[cljs-tooling "0.1.3" :exclusions [[org.clojure/clojure]]]
[compliment "0.2.1-20141130.115631-1" :exclusions [[org.clojure/clojure]]]
[defprecated "0.1.1"]
[org.clojure/java.classpath "0.2.0" :exclusions [[org.clojure/clojure]]]
[org.clojure/tools.trace "0.7.8" :exclusions [[org.clojure/clojure]]]
[org.tcrawley/dynapath "0.2.3" :exclusions [[org.clojure/clojure]]]
$ lein version
Leiningen 2.5.1 on Java 1.8.0_25 OpenJDK 64-Bit Server VM
My ~/.lein/profiles.clj:
{:user {:plugins [[cider/cider-nrepl "0.9.0-SNAPSHOT"]]
:dependencies [[org.clojure/tools.nrepl "0.2.7"]]}}
(exactly as https://stackoverflow.com/a/15172955/1047788 suggests)
Running lein repl in an empty directory:
$ lein repl
nREPL server started on port 40595 on host 127.0.0.1 - nrepl://127.0.0.1:40595
REPL-y 0.3.5, nREPL 0.2.6
Clojure 1.6.0
OpenJDK 64-Bit Server VM 1.8.0_25-b18
Docs: (doc function-name-here)
after creating a project with lein new app; cd app
$ lein repl
Retrieving org/clojure/clojure/1.6.0/clojure-1.6.0.jar from central
nREPL server started on port 55421 on host 127.0.0.1 - nrepl://127.0.0.1:55421
REPL-y 0.3.5, nREPL 0.2.7
Clojure 1.6.0
I am inclined to believe this might be a manifestation of some bug i Leiningen, but I am not sure... (why is it downloading clojure?)
UPDATED MAY/2021
Change your ~/.lein/profiles.clj file to the following:
{:user {:plugins [[cider/cider-nrepl "0.26.0-SNAPSHOT"]]
:dependencies [[nrepl "0.8.3"]]}}
Dependency specification for nrepl is referenced from cider-nrepl Clojars page.
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
I've a problem. I've installed clojure, slime, slime-repl and elein using marmalade. Now I open my project and call elein-swank. I get this:
Starting swank..
error in process filter: slime-presentation-init-keymaps: Symbol's function definition is void: slime-define-both-key-bindings
error in process filter: Symbol's function definition is void: slime-define-both-key-bindings
and If I try clojure-jack-in I get
Debugger entered--Lisp error: (error "Could not start swank server: That's not a task. Use \"lein help\" to list all tasks.
signal(error ("Could not start swank server: That's not a task. Use \"lein help\" to list all tasks.\n"))
error("Could not start swank server: %s" "That's not a task. Use \"lein help\" to list all tasks.\n")
clojure-jack-in-sentinel(#<process swank> "exited abnormally with code 1\n")
What can I do?
I'm not sure what elein is, but I think for clojure-jack-in you need to install the swank-clojure plugin:
lein plugin install swank-clojure 1.3.3
update: as of 2013, M-x nrepl-jack-in is preferred
The jack-in method is the preferred one, but you may also try the old favorite: run
$ lein swank
from the project's main dir, and then:
M-X slime-connect
from emacs. You still need swank-clojure:
$ lein plugin install swank-clojure 1.3.3
this happened to me when i cloned someone else's clojure project from an older version. their project.clj had:
:dev-dependencies [[lein-clojars "0.5.0"]
[swank-clojure "1.2.1"]]
which is incorrect, i think, if you're using M-x clojure-jack-in. removing these lines, running lein deps and jacking in worked for me.
If you're using lein 2, then try adding {:user {:plugins [[lein-swank "1.4.4"]] } } to ~/.lein/profiles.clj. see the Plugins section of https://github.com/technomancy/leiningen/wiki/Upgrading and https://github.com/technomancy/swank-clojure