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

0 votes
in tools.deps by

tools.deps.alpha does not take into account the "localRepository" directive from maven settings.xml.
According to the code (https://github.com/clojure/tools.deps.alpha/blob/dae323631f67cfdf1e4769c7a193f7b6373f448d/src/main/clojure/clojure/tools/deps/alpha/util/maven.clj) the local repository seems to
be hardcoded to $HOME/.m2/repository.
Is there an option to override that behavior?

1 Answer

+1 vote
by

You can set :mvn/local-repo at the root of your deps.edn to change the local repository location. This can be combined with -Sdeps to set it dynamically on the command line if needed:

clj -Sdeps '{:mvn/local-repo "/foo"}'

by
Thank you for your answer.
Note that it seems that I cannot make it work on Windows but I think it is linked to the specifics of that OS. I will test on wsl to confirm (or not) that.
clj -Sdeps '{:mvn/local-repo "D:/temp/m2repository"}'
Error building classpath. class clojure.lang.Symbol cannot be cast to class java.lang.String (clojure.lang.Symbol is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')
java.lang.ClassCastException: class clojure.lang.Symbol cannot be cast to class java.lang.String (clojure.lang.Symbol is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')
        at clojure.tools.deps.alpha.util.maven$make_local_repo.invokeStatic(maven.clj:136)
        at clojure.tools.deps.alpha.util.maven$make_local_repo.invoke(maven.clj:136)
        at clojure.tools.deps.alpha.util.maven$make_session.invokeStatic(maven.clj:195)
        at clojure.tools.deps.alpha.util.maven$make_session.invoke(maven.clj:192)
        at clojure.tools.deps.alpha.extensions.maven$eval1016$fn__1018$fn__1022.invoke(maven.clj:103)
        at clojure.tools.deps.alpha.util.session$retrieve.invokeStatic(session.clj:23)
        at clojure.tools.deps.alpha.util.session$retrieve.invoke(session.clj:14)
        at clojure.tools.deps.alpha.extensions.maven$eval1016$fn__1018.invoke(maven.clj:103)
        at clojure.lang.MultiFn.invoke(MultiFn.java:244)
        at clojure.tools.deps.alpha$expand_deps$children_task__763$fn__765$fn__766.invoke(alpha.clj:372)
        at clojure.tools.deps.alpha.util.concurrent$submit_task$task__500.invoke(concurrent.clj:33)
        at clojure.lang.AFn.call(AFn.java:18)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:834)
by
I suspect this is a shell quoting difference - you could try putting it in your deps.edn and see if that works to check.
by
Yeah, on Windows, you would use:

clj -Sdeps '{:mvn/local-repo ""D:\\temp\\m2repository""}'
by
I confirm that it works in the deps.edn and from the command line when escaping correctly the quotes:

Powershell: clj -Sdeps '{:mvn/local-repo ""D:/temp/m2repository""}'

Do you think it is worth raising an issue to have tools.deps read the localRepository directive in the maven user configuration (settings.xml)?
by
I'm not planning to add that, so no
...