Fork me on GitHub
#tools-deps
<
2019-08-30
>
andy.fingerhut21:08:35

FYI, I have used deps.edn to start both Clojure/Java and ClojureScript/Node.js REPLs, and run tests for each, for the core.rrb-vector that I have been experimenting with some proposed bug fixes for, here: https://github.com/jafingerhut/core.rrb-vector/blob/proposed-fixes-for-4-issues/deps.edn

andy.fingerhut21:08:34

It basically uses a bunch of aliases, some prefixed with ":clj-" and others with ":cljs-", for similar functionality in each Clojure flavor. The best alternative I could imagine to that approach would be to have two different directories with different deps.edn files, one for Clojure/Java, the other for ClojureScript.

andy.fingerhut21:08:14

Certainly open to other ideas if anyone thinks of improvements to that approach.

Felipe Cortez21:08:16

should add-lib work for every lib or are there limitations?

(require '[clojure.tools.deps.alpha.repl :refer [add-lib]])
(add-lib 'cheshire {:mvn/version "5.9.0"})
(require '[cheshire.core :as json])
fails with
Syntax error (ClassNotFoundException) compiling new at (cheshire/factory.clj:57:11).
com.fasterxml.jackson.core.async.ByteArrayFeeder
Syntax error compiling at (cheshire/core.clj:1:1).
namespace 'cheshire.factory' not found

dominicm21:08:19

Does it work if you include it in your deps.edn?

seancorfield21:08:00

I ran into something like this with clj-new and the Luminus template... as I recall it's a peculiarity of the Jackson library as far as its dependencies go...

seancorfield21:08:27

(or maybe it's a bug in how Cheshire is packaged?)

seancorfield21:08:55

I ended up needing to explicitly depend on various Jackson libraries in order to get that to succeed...

Alex Miller (Clojure team)21:08:17

add-lib will interpret new libraries in the context of your existing libs

Alex Miller (Clojure team)21:08:44

so if you already have an existing version of jackson on the classpath, and you add cheshire, it (can't) override the versions you already have

Alex Miller (Clojure team)21:08:00

if cheshire needs a newer version than the one you have, it may not work

Alex Miller (Clojure team)21:08:35

whereas if you had run a deps resolution on the full set of deps, it might have been able to resolve to a better set of deps

Alex Miller (Clojure team)21:08:55

jackson tends to be involved in 75% of dependency conflicts, so it's always a likely culprit

seancorfield21:08:57

Yeah, that sounds like the problem -- Cheshire/Jackson version mismatches.

Alex Miller (Clojure team)21:08:08

this is a totally normal thing that can happen with add-libs

seancorfield21:08:12

S3 wagon lib pulls in Jackson 2.5.5

Felipe Cortez21:08:37

makes sense, thanks!

seancorfield21:08:29

@clojurians884 Here's a combination that works:

(! 508)-> clj -A:deps -Sdeps '{:deps {com.fasterxml.jackson.core/jackson-core {:mvn/version "2.7.5"}}}'
Clojure 1.10.1
user=> (require '[clojure.tools.deps.alpha.repl :refer [add-lib]])
nil
user=> (add-lib 'cheshire {:mvn/version "5.6.3"})
true
user=> (require 'cheshire.core)
nil
user=> 

seancorfield21:08:59

Note the Jackson override on the command line. Without that, it won't work.

Felipe Cortez21:08:23

awesome! thanks for the help 🙂

seancorfield21:08:50

You don't need to add-lib on the smile sub-lib either (edited to remove that)

seancorfield21:08:45

If you want to use the latest Cheshire, you need Jackson 2.9.9:

(! 510)-> clj -A:deps -Sdeps '{:deps {com.fasterxml.jackson.core/jackson-core {:mvn/version "2.9.9"}}}'
Clojure 1.10.1
user=> (require '[clojure.tools.deps.alpha.repl :refer [add-lib]])
nil
user=> (add-lib 'cheshire {:mvn/version "RELEASE"})
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See  for further details.
true
user=> (require 'cheshire.core)
nil
user=> 

seancorfield22:08:19

(I would love to excise Cheshire and Jackson from our code base for exactly this reason!)

seancorfield22:08:07

(and the problem is because tools.deps brings in s3-wagon-private which in turn brings in Jackson 2.5.5 so you need an explicit override to make it all work)

Felipe Cortez22:08:28

do you recommend using data.json instead?

Alex Miller (Clojure team)22:08:55

I've got a spike of some work to use the cognitect s3 lib completely in place of the s3 wagon for tools.deps, would love to shift things over, but needs some work still (and prob streaming support in the s3 lib)

Alex Miller (Clojure team)22:08:29

I think the cognitect stuff uses data.json, which is definitely not as fast as cheshire/jackson (but way less problematic)

seancorfield22:08:00

If data.json does what you need -- and does it fast enough -- then, yes, use it instead of Cheshire to avoid the pit of dependency hell that is Jackson 🙂 But, in reality, you'll find it hard to avoid Cheshire as other libraries bring it in too...

seancorfield22:08:41

(having said that, I'm now having a hard time finding a single library that depends on Cheshire! oh how I wish that http://cross-clj.info was still alive!)

seancorfield22:08:34

(it was without - I think but that brings up an online casino that is squatting on the domain!)

Felipe Cortez22:08:47

again, thanks for the help 😄