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

+13 votes
in tools.deps by
recategorized by

When working with monorepos, specifically depending on libs defined in monorepos, it is common to see those pulled in via :git/url,tag,sha and :deps/root like:

; clojure -Sdeps '{:deps {polylith-kaocha/kaocha-wrapper
  {:git/url "https://github.com/imrekoszo/polylith-kaocha"
   :git/sha "d1fcd406cf0813b836419e39706ae61929a391a2"
   :deps/root "projects/kaocha-wrapper"}}}' -Stree | grep 'lambdaisland/kaocha'
    . lambdaisland/kaocha 1.68.1059

There are cases when it is beneficial for development or debugging to clone the monorepo and reference its libs using :local/root. However, simply replacing the git attributes and point to a local folder does not currently work (Clojure CLI version 1.11.1.1273):

; clojure -Sdeps '{:deps {polylith-kaocha/kaocha-wrapper
  {:local/root "/Users/ikoszo/imre/oss/polylith-kaocha"
   :deps/root "projects/kaocha-wrapper"}}}' -Stree | grep 'lambdaisland/kaocha'

(notice that lambdaisland/kaocha is not printed indicating it isn't in the dep tree)

As tools.deps currently appears to ignore :deps/root for :local/root dependencies, developers currently have to combine the two into :local/root like so:

; clojure -Sdeps '{:deps {polylith-kaocha/kaocha-wrapper
  {:local/root "/Users/ikoszo/imre/oss/polylith-kaocha/projects/kaocha-wrapper"}}}' -Stree | grep 'lambdaisland/kaocha'
    . lambdaisland/kaocha /Users/ikoszo/imre/oss/kaocha
    . lambdaisland/kaocha /Users/ikoszo/imre/oss/kaocha

At https://clojure.org/reference/deps_and_cli the following are currently stated:

Common coordinate attributes (all optional):
...
:deps/root - relative directory path within a file based dep to search for the manifest file

and

Local project attributes:
:local/root (required) - directory path (will auto detect whether a deps or pom project, also see :deps/manifest)

Reading the above, :local/root can qualify as a file based dep, which to me implies that :deps/root should work as it isn't stated otherwise.

Could support be added for this? This would make life easier switching between local and git deps when developing a library or tool.

If yes, this might also be a way to help solve at least a subset of the problem reported in https://clojure.atlassian.net/browse/TDEPS-132

(Originally asked and discussed in this slack thread: https://clojurians.slack.com/archives/C6QH853H8/p1682712720554439)

1 Answer

+6 votes
by
selected by
 
Best answer

Yes, should implement this.

Logged as https://clojure.atlassian.net/browse/TDEPS-246

by
Thank you Alex!
...