Fork me on GitHub

I’m trying to get a project of mine to where I can add library dependencies w/o restarting the REPL. I have org.clojure/tools.deps.alpha {:mvn/version "0.12.1067"} in :extra-deps for my :dev alias. But:

$ clojure -A:dev
Clojure 1.10.3
user=> (require '[ :refer [add-libs]])
Execution error (FileNotFoundException) at user/eval1 (REPL:1).
Could not locate clojure/tools/deps/alpha/repl__init.class, clojure/tools/deps/alpha/repl.clj or clojure/tools/deps/alpha/repl.cljc on classpath.
user=> ^D
$ clojure --version
Clojure CLI version
I don’t know how to debug this. Any tips?


I hadn't used it, but peeped the repo, and it appears that repl.clj is not in master, but rather in one of the add-lib branches, so pointing to that instead should sort you out.


Ah, thanks!

👍 1
Alex Miller (Clojure team)13:11:16

Yeah, you want the head of the addlib3 branch


Thanks. That’s the one I picked. 😃



"calva.customREPLCommandSnippets": [
            "key": "a",
            "name": "Add selected dependency",
            "snippet": "(require '[ :refer [add-libs]])\\n(add-libs '{$selection})"


I now add a dependency to deps.edn, select it, and ctrl+alt+space a. It has a very civilized feeling to it. 😃

Alex Miller (Clojure team)14:11:56

That's interesting as a use case. One thing we continue to discuss is whether this should be a) ad hoc b) change to deps.edn and “sync”, or c) change repl env and “push” to deps.edn. Seems like you've chosen b. We could provide that sync as an operation.

Alex Miller (Clojure team)14:11:42

I'm also not sure how to convey the “best attempt” nature of it and what to do if it can't be done or partially can't be done


Use 🤞 in function name so no one will want to put it in production code


sync-deps🙏 maybe

😂 4
🙏 1

This command snippet can be used ad-hoc as well. It doesn’t care if the dep is from a deps.edn or some fiddle-file or rich comment or line comment or whatever. I’m an optimist, so I add it to deps.edn 😃


(a) is probably my main use-case, since I think this will be most handy for me in an exploratory setting, when I have a short live command line repl for example. (b) would also be nice. Can we have both? add-libs and sync-libs ? I can also see the ad-hoc be useful for self-contained scripts. It could replace the weird bash comment hack. And instead you'd just have a normal shebang with some (add-libs) calls at the top.

Alex Miller (Clojure team)16:11:46

The script case is yet another use case that we have other ideas on (and really don't want to encourage too much outside this context - we'd really like the normal thing to be people defining the classpath externally)

Alex Miller (Clojure team)16:11:21

You will get the best results when you do version selection on all of your deps at one time - the “add one” approach is fraught with peril - there are many more ways to get a set of inconsistent libs


After thinking about it, I think I'd be happy with something that only does (b), and is more like a sync-deps, then an add-libs. For exploratory use cases I can just add things to my .clojure/deps.edn file and run sync-deps. I think forcing people into the externally defined habit is best, I wouldn't want to be in a scenario where I'm now worrying that some dependency I use is relying on dynamically pulling libs at runtime.


not done much reading around it yet - but on the off chance - has anyone recently installed and clojure-cli on MacOS with Nix?