I found a bug in cider-nrepl's plugin which misidentifies the current clojure version by investigating the deps and taking the first org.clojure/clojure
entry. Is there something built in that will give the correct clojure version?
*clojure-version*
if you are in a runtime
its in lein plugin stage so I don't know if *clojure-version*
would be the clojure-version the project will have, right?
sorry to drop extra information on you. But I think it would be unreliable at this stage, right? Lein will start up with its own clojure version while it assembles your project (if i understand the model correctly)
leiningen.core.classpath
probably has what you need: https://github.com/technomancy/leiningen/blob/master/leiningen-core/src/leiningen/core/classpath.clj#L528
the plot thickens. the middleware is run over the project twice. Fundamentally, nippy specifies clojure 1.5.1 in its deps and 1.10 in a profile and uses that profile in dev. CIDER-nrepl calls some with a predicate to get the clojure version on the dependencies and it returns the 1.5.1. However, this is run twice with the following deps in startup:
([nrepl "0.6.0"]
[org.clojure/clojure "1.10.0"]
[org.clojure/tools.reader "1.3.2"]
[com.taoensso/encore "2.106.0"]
[org.iq80.snappy/snappy "0.4"]
[org.tukaani/xz "1.8"]
[org.lz4/lz4-java "1.5.0"]
[nrepl/nrepl "0.6.0" :exclusions ([org.clojure/clojure])]
[clojure-complete/clojure-complete
"0.2.5"
:exclusions
([org.clojure/clojure])]
[org.clojure/test.check "0.9.0" :scope "test"]
[org.clojure/data.fressian "0.2.1" :scope "test"]
[org.xerial.snappy/snappy-java "1.1.7.2" :scope "test"])
and then again
([nrepl "0.6.0"]
[org.clojure/clojure "1.5.1"]
[org.clojure/tools.reader "1.3.2"]
[com.taoensso/encore "2.106.0"]
[org.iq80.snappy/snappy "0.4"]
[org.tukaani/xz "1.8"]
[org.lz4/lz4-java "1.5.0"]
[nrepl/nrepl "0.6.0" :exclusions [org.clojure/clojure]]
[clojure-complete "0.2.5" :exclusions [org.clojure/clojure]]
[org.clojure/clojure "1.10.0"]
[org.clojure/test.check "0.9.0" :scope "test"]
[org.clojure/data.fressian "0.2.1" :scope "test"]
[org.xerial.snappy/snappy-java "1.1.7.2" :scope "test"])
which only difference is this includes both Clojures and the exclusions of clojure-complete is a list of vectors now for some reasonthe result is that it identifies the clojure version as 1.5.1 the second time and doesn't inject cider-nrepl and the project dies in startup. And I can easily fix this but I don't understand why this is running twice, why clojure 1.5.1 is missing the first time
also, maven resolution should take the first coordinate so i'm not actually sure why it successfully starts up in 1.10 rather than 1.5.1
Isn’t the first the lein JVM and the second the project JVM?
What happens with lein trampoline
?
this is from the cider-nrepl.plugin
which i would expect to only run from the lein jvm and not the project jvm. I'll check lein trampoline now
Actually I think lein trampoline
still uses two JVMs, but stops the first one
lein trampoline exhibits the same behavior
https://github.com/technomancy/leiningen/blob/1dc131128279ef50f21d4d643c4d5c2133c1370d/doc/PLUGINS.md#project-middleware >Also note that the currently active middleware depends on which profiles are active. This means we need to reapply the middleware functions to the project map whenever the active profiles change. We accomplish this by storing the fresh project map and starting from that whenever we call merge-profiles, unmerge-profiles or set-profiles. It also means your middleware functions shouldn’t have any non-idempotent side-effects since they could be called repeatedly.
TIL 🙂
ok interesting. i still feel like we aren't seeing the actual deps. lein uses maven resolution which means if clojure 1.5.1 comes before 1.10 that should be the operative version in the project right? so i'm not sure how we could determine the actual version that will run