Cider version does not match cider-nrepl version in new luminus project - clojure

I'm experimenting with luminus, and all new luminus projects are giving me the cider version/ cider-nrepl version mismatch error when I connect to the repl started by lein run using emacs M-x cider-connect:
WARNING: CIDER's version (0.14.0) does not match cider-nrepl's version (nil). Things will break!
If I ignore the automatically started nrepl and use M-x cider-jack-in to start a new repl I don't see the error. This is what I would normally use for a clojure project but there appear to be certain things that don't work as well using luminus (starting and stopping an h2 database if I recall correctly, but that is another issue).
I have removed my ~/.lein/profiles.clj file and replaced it with one containing just the cider-nrepl plugin, ie:
{:user
{:plugins
[[cider/cider-nrepl "0.14.0"]]}}
I have also tried adding the plugin via the project.clj file but I still get the error.
lein deps :tree gives me a few possible conflicts and suggests exclusions, but none of them involve nrepl or cider.
What am I missing here?

I seems you are not using ciders nrepl but luminus-nrepl - therefor you get
not match cider-nrepl's version (nil)
if you create a luminus project like so
lein new luminus <project-name> +cider
the warning should disappear.
addendum, lein deps :tree (which was a good approach to analyse the problem)
without +cider
[luminus-nrepl "0.1.4"]
[org.clojure/tools.nrepl "0.2.12" :exclusions [[org.clojure/clojure]]]
with +cider
[cider/cider-nrepl "0.15.0-20170626.002218-19"]
[luminus-nrepl "0.1.4"]
[org.clojure/tools.nrepl "0.2.12" :exclusions [[org.clojure/clojure]]]

Related

configure lein-cloverage from project.clj

I started using cloverage with leiningen. I want to excude calls to assert from the coverage report.
The following command works fine for me:
$ lein cloverage --exclude-call clojure.core/assert
However, when I put :cloverage {:exclude-call ["clojure.core/assert"]} into the project.clj file and I just call $ lein cloverage, then the parameter is ignored.
How should I configure cloverage from my leiningen project file?
EDIT: I understand that I could create an alias easily with the followings, however, I would prefer configuring it a cleaner way:
:aliases {"coverage" ["cloverage" "--exclude-call" "clojure.core/assert"]}
Hopefully you found a solution. For anyone coming across this post now:
I put the cloverage options under my test profile in my project.clj. So, you could try something like this in project.clj:
:profiles {:test {:cloverage {:exclude-call ["clojure.core/assert"]}}}
When I run cloverage from the command line, I have to do $ lein with-profile test cloverage.
Also, here's the post I used when figuring this out: Can I make lein cloverage skip specific tests?

How to change Lein's Clojure default version outside of a project directory?

This is asking for help regarding the same question as How to change Clojure or Lein's Clojure default version?
but is not an answer to that question. Should I have nevertheless have written it as an answer under that thread?
Specifying a Clojure version to be used when the "(lein repl)" command is issued outside of a project directory seems to be a natural thing to want. Of course there may be good design reasons for not allowing it, but do you think an error message like the following,
to be displayed when Leiningen detects that the ~/.lein/profiles.clj (or other relevant profile files) specify a different Clojure version from the one hard coded into Leiningen,
would be a good idea?
"specifying the Clojure version to be used with certain software, such as tools.nrepl and clojure-complete, is only allowed when this command is issued within a project directory"
A lot of people apparently have spent a lot of time on Stack Overflow trying to find out how to do this.
References:
"Updating ~/.lein/profiles.clj to {:repl {:dependencies [^:displace [org.clojure/clojure "1.9.0"]]}} does not seem to work. – Petrus Theron Jan 10 2018 at 9:05" How do you change Clojure version in Leiningen and LightTable?
"I asked technomancy on IRC just now. He said: "REPL's outside projects are hard coded to lein's version of clojure". – David J. Feb 24 '14 at 19:52" How to change Clojure or Lein's Clojure default version?
"this ^:displace trick will not work with tools.nrepl or clojure-complete." https://github.com/technomancy/leiningen/blob/master/doc/PROFILES.md
How to upgrade nrepl version of leiningen?
I think you may try to declare different profiles in your project.clj where each of them has its own Clojure version. For example:
:profiles
{;; :default [:base :system :user :provided :dev]
:server-jvm {:jvm-opts ^:replace ["-server"]}
:1.5 {:dependencies [[org.clojure/clojure "1.5.1"]]}
:1.6 {:dependencies [[org.clojure/clojure "1.6.0"]]}
:1.7 {:dependencies [[org.clojure/clojure "1.7.0"]]}
:1.8 {:dependencies [[org.clojure/clojure "1.8.0"]]}
:1.9 {:dependencies [[org.clojure/clojure "1.9.0"]]}}
Now that, when running any Lein command, specify a profile as follows:
lein with-profile 1.7 repl
The REPL session of Clojure 1.7 should start.
I grabbed that fragment from carmine sources. The official Lein profiles manual also has the same example.

cljs/core.cljs [line 988, col 14] No reader function for tag Inf

I'm trying to launch the latest stable [org.clojure/clojurescript "1.9.946"], using boot-cljs and getting this error: cljs/core.cljs [line 988, col 14] No reader function for tag Inf.
I've learned that 1.9.946 introduced new ##Inf syntax: https://cljs.github.io/api/syntax/Inf. but not sure why I'm getting this error. I've also tried to do this: [adzerk/boot-cljs "2.1.4" :exclusions [org.clojure/clojurescript]] but it changed nothing.
Edit: just tried to build cljs version from repo and hooked up npm deps with lein-npm, server rendering of react worked as expected. May be something to do with boot-cljs deps or some other my components.
Support for ##Inf was added in tools.reader 1.1.0, which ClojureScript 1.9.946 depends upon.
If you see this error, it is because you have tools.reader 1.0.6 or earlier on your classpath.
Note that, while ClojureScript 1.9.946 specifies [org.clojure/tools.reader "1.1.0"] as a dependency, explicitly specifying an older version in your project configuration would cause the issue.
Also note that this is independent of the Clojure version being used. If desired, you can run the ClojureScript 1.9.946 compiler using Clojure 1.8.0 and successfully compile ClojureScript code that makes use of ##Inf; Clojure 1.9.0 is not required.

How can I run lein repl outside of a project?

I spent some time last night messing with my leinigen profiles.clj to get rid of all the errors that were being printed when starting cider in my project. Today I went to start a repl from the terminal (I like to keep one open while I work) but it didn't work. I thought it was a cider issue so I tried it from Emacs but even in Emacs if I'm not in a project the repl won't start.
Here's the error:
Error loading refactor-nrepl.middleware: clojure.lang.ArityException: Wrong number of args (4) passed to: StringReader, compiling:(abnf.clj:186:28)
Exception in thread "Thread-4" java.lang.RuntimeException: Unable to resolve var: refactor-nrepl.middleware/wrap-refactor in this context, compiling:(NO_SOURCE_PATH:0:0)
...
Caused by: java.lang.RuntimeException: Unable to resolve var: refactor-nrepl.middleware/wrap-refactor in this context
My ~/.lein/profiles.clj
{:user {:plugins [[lein-try "0.4.3"]
[refactor-nrepl "1.1.0"]
[cider/cider-nrepl "0.9.1"]]
:dependencies [[org.clojure/tools.nrepl "0.2.12"]
[acyclic/squiggly-clojure "0.1.4"]
^:replace [org.clojure/tools.nrepl "0.2.12"]
[refactor-nrepl "1.1.0"]]}}
The versions of things when cider starts in a project
; CIDER 0.9.1 (Java 1.8.0_45, Clojure 1.7.0, nREPL 0.2.12)
I'm still pretty new to Clojure, Leinigen, Emacs, etc so I'm not sure why everything above made made my cider errors go away but it did. The cider errors I was getting were having to do with the nrepl version being too low and not having certain things installed (like refactor-nrepl).
When starting a repl from lein using lein repl, it really wants to run in a lein project dir. I keep an empty lein project named clj around in my home dir for this purpose. That way, my common dependencies are already there in the project.clj file, and lein is pre-configured just the way I like it.
You can start lein repl in an empty dir, but you get 10-20 error messages each time before it starts.
Another way is to use the plain repl built into the clojure jar file:
~/dummy > cp /home/alan/.m2/repository/org/clojure/clojure/1.8.0-RC1/clojure-1.8.0-RC1.jar .
~/dummy > d *
-rw-rw-r-- 1 alan alan 3935726 Nov 19 14:11 clojure-1.8.0-RC1.jar
~/dummy > java -jar clojure-1.8.0-RC1.jar
Clojure 1.8.0-RC1
user=>
As you can see, I created an empty directory named dummy and copied in the clojure-*.jar file. You can then run it with the syntax java -jar xxx.jar and it will fire up a repl completely independently of lein.
I also just keep a scratch project which I use for quick/simple repl sessions. There is a lien-oneoff plugin which is supposed to make it easy to work with simple single file lein projects which might be useful.
The other thing you could do is setup a boot config for basically getting a repl up to work with
what is your lein version, I am use 2.5.3, I can start lein repl anywhere.
Shell:~ >: lein repl
nREPL server started on port 52343 on host 127.0.0.1 - nrepl://127.0.0.1:52343
REPL-y 0.3.7, nREPL 0.2.10
Clojure 1.7.0
Java HotSpot(TM) 64-Bit Server VM 1.8.0_60-b27
Docs: (doc function-name-here)
(find-doc "part-of-name-here")
Source: (source function-name-here)
Javadoc: (javadoc java-object-or-class-here)
Exit: Control+D or (exit) or (quit)
Results: Stored in vars *1, *2, *3, an exception in *e
user=> Bye for now!
Shell:~ >: lein version
Leiningen 2.5.3 on Java 1.8.0_60 Java HotSpot(TM) 64-Bit Server VM
Shell:~ >: cat .lein/profiles.clj
{:1.2 {:dependencies [[org.clojure/clojure "1.2.0"]]}
:1.3 {:dependencies [[org.clojure/clojure "1.3.0"]]}
:1.4 {:dependencies [[org.clojure/clojure "1.4.0"]]}
:user {:plugins [[lein-immutant "2.0.0-alpha2"]
[lein-clojars "0.9.1"]
[lein-ancient "0.5.5"]
[lein-kibit "0.0.8"]
[lein-try "0.4.3"]
[venantius/ultra "0.2.0"]]
:ultra {:color-scheme :solarized_dark}}}

Clojure ring server seems to be missing dependencies on slf4j

I've been trying to follow a number of tutorials on building a web app in Clojure, but I keep running into the same problem. To take the simplest case, I tried following this tutorial: http://drtom.ch/posts/2012-12-10/An_Introduction_to_Webprogramming_in_Clojure_-_Ring_and_Middleware/
When I get to the step that starts the server (run-jetty handler {:port 8383}), I get the following error:
NoSuchMethodError org.slf4j.helpers.MessageFormatter.arrayFormat(Ljava/lang/String;[Ljava/lang/Object;)Lorg/slf4j/helpers/FormattingTuple; org.eclipse.jetty.util.log.JettyAwareLogger.log (JettyAwareLogger.java:613)
I asked lien to show me the classpath, and sure enough, org.slf4j.helpers.MessageFormatter isn't in there anywhere.
I've run into this on pretty much every ring-based web tutorial I've tried, so either I've got something configured weird (I updated and reinstalled lein, blew away my ~/.m2 and rebuilt, etc), or something has changed in the myriad dependencies that get put together to make the classpath.
Any ideas what's going on here?
EDIT
I've got further information -- I created a VM in virtualbox, installed OpenJDK and lein, and created a project there. It worked fine. Since I had created it in a directory shared with the host, I then tried doing "lein ring server" in the same directory from the host, and it failed with the above error.
So I did "lein classpath" both in the vm and in the host and compared the results -- they're identical. I also checked that they're running the same build of the same JVM (OpenJDK 64-bit build 24.51-b03).
So, if they're running the same JVM with identical classpaths, what's left?
Can you try updating the dependencies like the following?
(defproject ..........
:dependencies [[org.clojure/clojure "1.5.1"]
[ring/ring-core "1.1.8"]
[ring/ring-jetty-adapter "1.1.8"]
[compojure "1.1.3"]]
:main quickstart.core
:min-lein-version "2.0.0"
:plugins [[lein-ring "0.8.10"]]
:ring {:handler quickstart.core/handler})
If you use the lein ring plugin as configured above, you can start the application like:
lein ring server