leiningen

N.B. The maintainers are on #leiningen on Libera chat IRC. Go there for direct support/bug reports.
dpsutton 2019-03-10T17:21:25.053500Z

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?

alexmiller 2019-03-10T17:31:23.054500Z

*clojure-version* if you are in a runtime

dpsutton 2019-03-10T17:32:55.055100Z

its in lein plugin stage so I don't know if *clojure-version* would be the clojure-version the project will have, right?

dpsutton 2019-03-10T17:34:08.056400Z

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)

cichli 2019-03-10T17:54:37.057100Z

leiningen.core.classpath probably has what you need: https://github.com/technomancy/leiningen/blob/master/leiningen-core/src/leiningen/core/classpath.clj#L528

dpsutton 2019-03-10T18:01:45.059900Z

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 reason

dpsutton 2019-03-10T18:02:47.060900Z

the 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

dpsutton 2019-03-10T18:03:10.061600Z

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

cichli 2019-03-10T18:04:48.062Z

Isn’t the first the lein JVM and the second the project JVM?

cichli 2019-03-10T18:05:00.062300Z

What happens with lein trampoline?

dpsutton 2019-03-10T18:05:52.063100Z

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

cichli 2019-03-10T18:07:12.063700Z

Actually I think lein trampoline still uses two JVMs, but stops the first one

dpsutton 2019-03-10T18:07:14.063900Z

lein trampoline exhibits the same behavior

cichli 2019-03-10T18:11:20.064400Z

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.

cichli 2019-03-10T18:12:06.064800Z

TIL 🙂

dpsutton 2019-03-10T18:22:53.065700Z

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