Hello! I’m using the practicalli application template and REPL tooling from inside Emacs with CIDER. When I use the user namespace, it seems like some of the additional REPL functionality is available — for example, I can run (help) or (namespace/refresh) — and some isn’t:
user> (sync-deps)
Syntax error compiling at (*cider-repl repos/parts:localhost:51248(clj)*:142:7).
Unable to resolve symbol: sync-deps in this context
user> (add-lib 'aero)
Syntax error compiling at (*cider-repl repos/parts:localhost:51248(clj)*:145:7).
Unable to resolve symbol: add-lib in this context
Am I missing some configuration?Oh I see, there is this bit in dev/user.clj:
;; ---------------------------------------------------------
;; Hotload libraries into running REPL
;; `deps-*` LSP snippets to add dependency forms
(comment
;; Require for Clojure 1.11.x and earlier
(require '[clojure.tools.deps.alpha.repl :refer [add-libs]])
(add-libs '{domain/library-name {:mvn/version "1.0.0"}})
;; Clojure 1.12.x only
#_(add-lib 'library-name) ; find and add library
#_(sync-deps) ; load dependencies in deps.edn (if not yet loaded)
#_()) ; End of rich comment
;; ---------------------------------------------------------
I guess this means I need to add those requires to my user namespace if I’m running Clojure 1.11.x (which I am)Or maybe just upgrade to 1.12
I found the docs: https://practical.li/clojure/clojure-cli/repl/libraries/#hotload-libraries
Yes, you found the right info. I will endeavour to make it clearer to understand.
I do recommend using 1.12, especially once there is a stable release.
The project templates take an argument to set the version of Clojure, :clojure-version "1.12.x"
Although hot loading should work well with 1.11, the original add-libs library for 1.11 is no longer maintained and may have dependencies that are many versions behind.
I will rewrite the hot load page once 1.12 is the default stable version and move the 1.11 examples to the reference section.
I guess I could check what version of clojure is being used and include the relevant hotload code in the user namespace, but I would need to find a nice way to do that than I am currently using.
Thank you @jr0cket! I’ve switched to the 1.12 RC in my deps.edn, is there anything I need to change about the files generated by the template to accomodate?
Optionally, update the clojure version in the pom.xml file. This should only be used when packaging an uberjar. The Clojure CLI can update the pom.xml
clojure -SpomThank you!