Display complete dependency tree with Leiningen
Asked Answered
R

3

33

I understand that lein deps :tree displays a dependency tree of all the project dependencies (implicit and explicit). However, "each dependency is only shown once within a tree." I'd really like to see a tree where this wasn't the case, and that if libraries A and B require library X, library X shows up under both A and B.

Does anyone know how to do this with lein or some other tool?

Rondo answered 13/10, 2015 at 3:53 Comment(0)
W
3

This can be done without Leiningen using tools.deps. With a minimal deps.edn file like:

{:deps {}}

Then view the tree with:

% clj -Stree
org.clojure/clojure 1.10.1
  org.clojure/spec.alpha 0.2.176
  org.clojure/core.specs.alpha 0.2.44
Waler answered 7/1, 2020 at 22:56 Comment(2)
I appreciate the tools.deps (which I'm now using) answer, but unfortunately, this doesn't answer the question. As with lein deps :tree, clj -Stree only prints each dep once, and so it's not as useful for determining where there might be a dependency conflict.Rondo
It seems this has changed recently, and now clj -Stree does print out everything?Whosoever
F
44

You can generate Maven's POM out of Leiningen's project definition and then use Maven's dependency:tree plugin with a verbose option, like this:

$ lein pom
$ mvn dependency:tree -Dverbose=true 

This will list dependencies omitted for various reasons, e.g.:

|  +- ring:ring-core:jar:1.4.0:compile
|  |  +- (org.clojure:clojure:jar:1.5.1:compile - omitted for conflict with 1.7.0)
|  |  +- (org.clojure:tools.reader:jar:0.9.1:compile - omitted for conflict with 0.10.0-alpha3)
|  |  +- (ring:ring-codec:jar:1.0.0:compile - omitted for duplicate)

For more options to dependency:tree see its documentation.

Facelift answered 13/10, 2015 at 10:29 Comment(1)
Brilliant. Thanks. For those who don't have access to mvn, you can run sudo apt-get install maven on Ubuntu.Rondo
G
40

This can now be done using leiningen by lein deps :tree. Note the space between deps and :tree.

Gormley answered 7/7, 2017 at 4:59 Comment(3)
At the time of writing, this command doesn't show an actual tree. It uses indentation to indicate dependencies, which makes it a pain to read.Ixion
The OP mentions that they are using lein deps :tree already.Sterculiaceous
PLEASE STOP VOTING FOR THIS ANSWER!!! The author seems to have barely read my post, as I stand by saying "I understand that lein deps :tree ...". This answer does not solve the problem.Rondo
W
3

This can be done without Leiningen using tools.deps. With a minimal deps.edn file like:

{:deps {}}

Then view the tree with:

% clj -Stree
org.clojure/clojure 1.10.1
  org.clojure/spec.alpha 0.2.176
  org.clojure/core.specs.alpha 0.2.44
Waler answered 7/1, 2020 at 22:56 Comment(2)
I appreciate the tools.deps (which I'm now using) answer, but unfortunately, this doesn't answer the question. As with lein deps :tree, clj -Stree only prints each dep once, and so it's not as useful for determining where there might be a dependency conflict.Rondo
It seems this has changed recently, and now clj -Stree does print out everything?Whosoever

© 2022 - 2024 — McMap. All rights reserved.