How to see dependency tree in sbt?

When run from the command line, each argument sent to sbt is supposed to be a command, so sbt inspect tree cleanwill:

  • run the inspect command,
  • then run the tree command,
  • then the clean command

This obviously fails, since inspect needs an argument. This will do what you want:

sbt "inspect tree clean"

If you want to view library dependencies, you can use the coursier plugin: https://github.com/coursier/coursier/blob/master/doc/FORMER-README.md#printing-trees

Output example: image text (without colors): https://gist.github.com/vn971/3086309e5b005576533583915d2fdec4

Note that the plugin has a completely different nature than printing trees. It's designed for fast and concurrent dependency downloads. But it's nice and can be added to almost any project, so I think it's worth mentioning.


If you want to actually view the library dependencies (as you would with Maven) rather than the task dependencies (which is what inspect tree displays), then you'll want to use the sbt-dependency-graph plugin.

Add the following to your project/plugins.sbt (or the global plugins.sbt).

addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.2")

Then you have access to the dependencyTree command, and others.


With sbt 1.4.0, dependencyTree task is available in sbt without using plugins.

sbt dependencyTree

sbt-dependency-graph is included in sbt 1.4.0: https://www.scala-sbt.org/1.x/docs/sbt-1.4-Release-Notes.html#sbt-dependency-graph+is+in-sourced

Full strength dependency tree can be enabled by adding addDependencyTreePlugin to project/plugins.sbt.

List of available commands: https://github.com/sbt/sbt-dependency-graph#usage-instructions