This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-04-20
Channels
- # announcements (4)
- # babashka (10)
- # beginners (8)
- # calva (13)
- # cherry (20)
- # cider (9)
- # clojure (11)
- # clojure-austin (2)
- # clojure-europe (3)
- # clojure-norway (3)
- # clojurescript (1)
- # datomic (5)
- # dev-tooling (9)
- # fulcro (5)
- # hyperfiddle (5)
- # instaparse (1)
- # lingy (1)
- # malli (21)
- # matrix (1)
- # missionary (9)
- # off-topic (12)
- # releases (2)
- # ring-swagger (8)
- # scittle (9)
- # shadow-cljs (20)
Question about clojure.tools.namespace
. In past projects, I have used ns-tracker
to reload namespaces on a locally running server. This worked well but I would like to transition to tools.namespace
as it seems to be more robust in its handling of dependencies and namespace reloading. However, tools.namespace.repl/refresh
does not work when I run it in a separate thread, which makes it challenging to use in combination with ns-tracker
. The specific error I receive is this:
Exception in thread "Thread-0" java.lang.IllegalStateException: Can't change/establish root binding of: *ns* with set
There could be something I'm doing incorrectly when setting this up. I'm not particularly wedded to ns-tracker
. Primarily, I would like to know what the proper way to do hot reloading of server code (running on a local machine) with clojure.tools.namespace
?It's more idiomatic to stop using ns-tracker and use t.n in conjunction with Component to also manage your local server or other such 'components'
Here's a nice template https://github.com/stuartsierra/reloaded (even if you weren't using Lein, you can just peek at the files)
We are using polylith but I’m sure we can modify to make it work.
Lastly, generally, don't do any sort of code (re)loading from a parallel thread - require
and friends are thread-unsafe, as of today
So is it best practice now to just move off of ns-tracker
?
https://github.com/tonsky/clj-reload aspires to be tools.namespace's successor , I'd say it's doing a good job at that and it already has CIDER support (personally I keep using t.n but I'm a cranky dev)