Welcome! Please see the About page for a little more info on how this works.

+7 votes
in tools.deps by

Leiningen has a feature called Managed Dependencies. This lets you set a common version for a transitive dependency to be used instead of relying on versions provided by your dependencies. This is useful when you want to specify a version of a library without actually adding a dependency on it. It has a very similar effect (I think) as adding the dependency directly to your Leiningen :dependencies, but communicates the intention better.

Is there something similar like this in deps.edn? A way to specify a version resolution for a dependency without adding it directly to :deps?

2 Answers

+4 votes

At work we rely heavily on :override-deps in a project-wide deps.edn file (we use CLJ_CONFIG to pick up that instead of the user-level deps.edn file). We have an alias called :defaults that has :override-deps with an entry for everything dependency that we want to "manage".

Our (mono-)repo has a versions folder containing that project-wide file and then each subproject in the repo has its own deps.edn file where we specify dependencies like this:

selmer {} ; omit :mvn/version "x.y.z"

And versions/deps.edn has:

  {selmer {:mvn/version "1.12.13"}

Then we do this inside a subproject:

CLJ_CONFIG=../versions clojure -A:defaults <whatever else we need>
+1 vote

The similar use case in deps is :default-deps which allows you to set the default deps to use when the version is undefined. However, we have never actually specified how to include a dep without a version such that the default will get picked up.

Also, we probably need more flexibility in specifying a base deps.edn which could be a place to state those default deps.

So, it’s still a work in progress.

Hi @alexmiller,
I like :default-deps!
What's the best way to pull it in?

What I'd like is root directory containing blessed-versions.edn or similar,
and then sub directories with a deps.edn that has "nil" as the version, and pulls in the "blessed version"... is that achievable without using CLJ_CONFIG (which conflicts with user configuration)?
Currently, no I don’t think so.
Did we specify "how to include a dep without a version such that the default will get picked up" yet? @alexmiller
No update, but I think https://ask.clojure.org/index.php/9849/teams-common-dependencies-tooling-across-multiple-projects is probably the place to vote/watch for updates on this.