tools-deps

2026-02-15T15:57:53.323149Z

It seems that I cannot specify the repositories to use when using clojure.repl.deps/add-lib, correct ? If so, which are used ?

dpsutton 2026-02-15T16:33:54.909729Z

seems to use the configured ones

clj -Sdeps '{:mvn/repos {"metabase-maven-downloads" {:url ""}}}'
Clojure 1.12.1
user=> (add-lib 'com.metabase/athena-jdbc {:mvn/version "3.7.0"})
[com.metabase/athena-jdbc]
user=>
vs
❯ clj
Clojure 1.12.1
user=> (add-lib 'com.metabase/athena-jdbc {:mvn/version "3.7.0"})
Execution error (ExceptionInfo) at clojure.tools.deps.interop/invoke-tool (interop.clj:81).
Could not find artifact com.metabase:athena-jdbc:jar:3.7.0 in central ()

2026-02-15T16:34:31.278279Z

Yes, so these cannot be changed at "runtime" ?

dpsutton 2026-02-15T16:34:52.479819Z

perhaps you could add a new one and call sync-deps?

dpsutton 2026-02-15T16:35:44.375629Z

sync deps doesn’t seem to register it

2026-02-15T16:35:59.652779Z

hmm In my scenario there is not 'deps.edn`. I run clojure as part of an "uberjar".... So I do indeed wonder if add-lib supports this scenario at all.

dpsutton 2026-02-15T16:36:40.285369Z

i believe those functions only work when the repl is started with clj and clojure

2026-02-15T16:37:20.002979Z

Is this confirmed and somehwhere written ? I searched for it, but could not really find it.

dpsutton 2026-02-15T16:37:54.032089Z

user=> (doc add-lib)
-------------------------
clojure.repl.deps/add-lib
([lib coord] [lib])
  Given a lib that is not yet on the repl classpath
repl classpath

dpsutton 2026-02-15T16:38:27.153349Z

i remember hearing it, i think they had to add some env variable set by clj and clojure that it registers

dpsutton 2026-02-15T16:39:23.294489Z

the source of add-lib contains this: procurer (select-keys (basis/current-basis) [:mvn/repos :mvn/local-repo]) and the current basis will of course only be meaningful in a process started by clj or clojure

2026-02-15T16:39:41.092239Z

yes... So this feature works completely different then pomegranate ?

user=> (require '[cemerick.pomegranate :as pom]
                '[cemerick.pomegranate.aether :as aether])
nil
user=> (pom/add-dependencies :coordinates '[[incanter "1.9.2"]]
                             :repositories (merge aether/maven-central
                                                  {"clojars" ""}))
;...add-dependencies returns full dependency graph here...
user=> (require '[incanter core stats charts])
nil

2026-02-15T16:39:58.148459Z

which does work "without repl".

dpsutton 2026-02-15T16:40:15.712439Z

yes it does work differently

dpsutton 2026-02-15T16:40:58.825299Z

just because i’m interested, why are you trying to dynamically add deps in an uberjar context?

2026-02-15T16:41:00.441299Z

Ok. For a while I understood it as an "clojure build in, official replacement".

2026-02-15T16:41:29.379009Z

https://github.com/clojupyter/clojupyter

2026-02-15T16:42:09.639099Z

In there "clojure" and "all librraies" need to be packed as an uberjar. The uberjar is the "jupyter kernel".

dpsutton 2026-02-15T16:42:16.672369Z

ah. you are kind of a runtime yourself

2026-02-15T16:43:03.035219Z

they provide this to add libs at runtime: https://github.com/clojupyter/clojupyter/blob/main/src/clojupyter/misc/helper.clj

2026-02-15T16:43:38.082739Z

and it seems to work. I was just wondering about using "add-lib" instead.

Alex Miller (Clojure team) 2026-02-15T17:24:24.949829Z

I can confirm that it’s going to use the repos from deps.edn, and I don't think it will pick up new ones even if you sync-deps, although maybe that would be possible

2026-02-15T17:40:26.494659Z

Is that something which could be added ? Because it uses the once from the base, but it would work if we simply could specify others ? And if "specifying repos" would work, would it then allow to add libs dynamically in my scenario of using a uberjar with clojure and not the "clojure" / "clj" cli tools ? Otherwise asked : Is add-lib only supported / working 'by principle' when using the "clojure" cli ?

Alex Miller (Clojure team) 2026-02-15T17:51:45.446509Z

Can you file an ask Clojure for the repo thing?

Alex Miller (Clojure team) 2026-02-15T17:53:42.495449Z

add-libs uses the CLI so requires it, but you can also use https://github.com/nubank/lein-add-libs to source the basis from project.clj

Alex Miller (Clojure team) 2026-02-15T18:09:45.933739Z

Don’t understand the uberjar question exactly but they kind of break the model in that you lose all the info about what libs are expanded inside the uberjar. add-lib is trying to resolve new libs against the existing loaded libs, which it can no longer know

2026-02-15T18:18:18.051229Z

As Illustration: This jar https://github.com/scicloj/noj/releases/download/2-beta19.1/noj-2-beta19.1-uber.jar contains "clojure" (among other libraries ) I can run it as clojure repl by:

java -cp noj-2-beta19.1-uber.jar clojure.main
But inside of this repl, add-lib fails, on first sight because no repo is found, as there is no "basis". You seem to say, even if i could specify repos, it would still not work , correct ?
(add-libs '{http-kit/http-kit {:mvn/version "2.5.1"}})
Execution error (ExceptionInfo) at clojure.tools.deps.interop/invoke-tool (interop.clj:81).
Could not find artifact http-kit:http-kit:jar:2.5.1
user=> 

2026-02-15T18:20:23.091229Z

The use case is a bit of having a "closed world" of an uberjar, which still can be extended from "inside"... So it is "half closed".... An other "projects" uses this type of uber jars as well: https://github.com/clojupyter/clojupyter Here the "jupyter kernel" need to be an uberjar contain clojure itself. (and all libraries needed, which is inflexible)

2026-02-15T18:22:09.005709Z

clojupyter allows so far the classpath extension using : https://github.com/clojupyter/clojupyter/blob/797261501b6c0f11a600f6030d720fa9157005d8/src/clojupyter/misc/helper.clj#L18

Alex Miller (Clojure team) 2026-02-15T18:37:44.960439Z

These are not use cases add-libs is trying to cover

2026-02-15T18:38:19.683139Z

Thanks for confirmation.👍

Alex Miller (Clojure team) 2026-02-15T18:39:34.223889Z

It would be possible to alter the basis using the impl/non-public api in c.java.basis.impl to add repos or even describe the actual dep set

Alex Miller (Clojure team) 2026-02-15T18:40:13.309499Z

Depends how far outside the lines you want to color :)