At Liftoff (liftoff.io), we have 34 clojure projects comprising over 1M lines of code. We use a monorepo and ran into the problem described in this thread while switching from leiningen to the Clojure CLI tools.
I think this issue could be addressed by turning relative paths into absolute paths upon reading the deps.edn files in clojure.tools.deps.alpha.reader/slurp-deps
. Here is a short patch suggesting a fix for relative paths in :local/root
coordinates.
Here is a full description of our use-case:
In a monorepo, the clojure CLI's config-dir deps.edn file might
contain relative paths to other parts of the repo.
For example, let's consider the following monorepo.
config/
clojure/
deps.edn
tools/
lint/
deps.edn
src/...
B/
deps.edn
src/..
A/
deps.edn
src/...
Let's image we want to add a repo-wide linting alias in
config/clojure/deps.edn.
{:aliases
{:lint {:extra-deps {acme/lint {:local/root ../../tools/lint}}
:main-opts ["-m" "acme.lint.core"]}}}
Developers set CLJ_CONFIG="config/clojure/deps.edn" in their shell
configuration. Clojure linting code lives at "tools/lint/deps.edn".
In all projects in the repo (e.g. at "A/deps.den", and
"tools/B/deps.den"), we would like clojure -A:lint
to run the
linters.
Running clojure -A:lint
in directory A, however, adds
"A/../../tools/lint/src" to the classpath, rather than
"A/../tools/lint/src" or "/path/to/repo/tools/lint/src".
Thank you to the clojure team for the incredible work you've been doing over the years!