This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-08-16
Channels
- # announcements (3)
- # babashka (48)
- # beginners (35)
- # calva (3)
- # chlorine-clover (5)
- # clj-kondo (9)
- # cljdoc (20)
- # cljsrn (1)
- # clojure (55)
- # clojure-europe (33)
- # clojure-nl (3)
- # clojure-norway (6)
- # clojure-spec (7)
- # clojure-uk (27)
- # clojurescript (95)
- # closh (1)
- # conjure (1)
- # cursive (16)
- # datomic (30)
- # emacs (7)
- # honeysql (1)
- # hugsql (2)
- # introduce-yourself (2)
- # jobs (1)
- # lsp (30)
- # malli (22)
- # nbb (11)
- # news-and-articles (1)
- # off-topic (8)
- # pathom (21)
- # polylith (41)
- # portal (4)
- # practicalli (4)
- # protojure (1)
- # re-frame (14)
- # releases (1)
- # restql (1)
- # reveal (24)
- # sci (1)
- # sql (21)
- # vim (11)
- # xtdb (33)
When visiting a Clojure file in a base, I invoke cider-jack-in
, this starts a REPL which reads the dep.edn
file of the base, what I intended was to read the deps.edn
file in the root of the workspace, has anyone had this problem and found a way around this? (I am aware that this is the correct behaviour, just wondering if anymore has a work around to always read the workspace deps.edn
config)
I always do the initial connect to the REPL via the user or dev ns in the development project.
Yea I've been doing the same
@U05476190 how do you setup the nrepl?
I just run clojure -M:with:lots:of:dev:aliases
and then cider-connect-clj
. I never figured out how to use cider-jack-in
and find it easier to configure the REPL classpath via CLI tools :)
At work we always start the REPL from the terminal because our REPL outlives our editor sessions (we run REPLs for days or weeks -- or sometimes months) but our editors tend to get restarted a lot more often.
My work REPL has been running since August 11th at this point (not very long) but my HoneySQL project REPL has been running since July 18th.
(and my depstar project REPL has been running since July 9th)
My work REPL is started like this:
(! 509)-> SOCKET_REPL_PORT=5000 clojure -Sforce -M:rebel:reflect:jedi-time:reveal:j14:classes:everything:dev:test:build:runner:dev/repl
That :dev/repl
alias comes from my dot-clojure repo setup on GitHub and starts Rebel Readline, Reveal, and a Socket REPL, plus it adds some customizations to Reveal.:dev:test
is the Polylith portion. :everything:runner
is our legacy subproject stuff. :build
is our build.clj
stuff with tools.build
. :reflect
is Stu Halloway's reflector utility to improve datafy/nav for namespaces. :j14
enables some JVM options to improve error reporting (well "improve" is subjective). And :classes
adds the classes
folder where I have AOT'd code for some dev load improvements (per the http://clojure.org page about that -- but I don't really use it much). Normally, I'd also have :add-libs
in there for adding dependencies on-the-fly (but recently it has conflicted with tools.build
so I haven't bothered -- although Alex just merged master to the add-lib3 branch so I may pick that up again).
kool, thanks for the info, I guess starting the REPL from the command line is the way to go, or a clunky jack in if one must
@allandaviesza just ran into this, so I wrote a quick hack for it
(after! clojure
;; (setq clojure-cache-project-dir nil) ; you may need this
(defun locate-submissive-file (file name)
(let ((it (locate-dominating-file file name)))
(while-let ((maybe-descend-to-parent (and it (locate-dominating-file (file-name-parent-directory it) name))))
(setq it maybe-descend-to-parent))
it))
(setq clojure-project-root-function
(defun my/clojure-project-root-path (&optional dir-name)
(or (locate-submissive-file (or dir-name default-directory) "deps.edn")
(clojure-project-root-path dir-name)))))
What's a good way to have a def
that a component both uses & exposes? The polylith tool readme suggests putting something like (def one-two-three 123)
in the interface, but then the component's implementation can't access the value (because of the circular dependency implementation -> interface -> implementation). The obvious thing is to have an interface def
that points to an implementation def
, but then you can't with-redefs
it for testing.
The most common thing I've seen if (def one-two-three 123)
in the implementation and then (def one-two-three impl/one-two-three)
in the interface. with-redefs
can be fairly problematic so I'd question how you get yourself into a situation that needs to redef a def
(as opposed to a defn
).
If you have a global value, it's going to get compiled into the functions that use it so with-redefs
on such a value isn't going to work anyway.
There's a test that was written for the non-Polylith repo that with-redefs
the var
That's a problem with the current test then I'd say - per above : Def values will be compiled into uses and can't generally be redefd
(sorry for typos - power just went out and I'm on my phone now)
Yikes!
I'm not sure what you mean by "global value"? I just have a def
for something that depends on how the program was started. And that needs to be tested with multiple values.
(def abc impl/abc)
(defmacro with-custom-abc* [new-abc & body]
`(with-redefs [impl/abc new-abc]
(do ~@body)))
My def
is for a system property
I don't think that macro quite works? It needs to redef both the core and interface var (as I have discovered the hard way.)
(def abc impl/abc)
(defmacro with-custom-abc* [new-abc & body]
`(with-redefs [abc new-abc
impl/abc new-abc]
(do ~@body)))
I think so. I almost want to put it in the core file, just to emphasize that it's not really for public use.
which introduces some indirection, which would let you get away with only redeffing one
Having a global def
just reading off the environment when the ns is loaded is a very bad idea since it'll run when you AOT your code as well as when you require the ns -- that's essentially a side-effect (dependent on the state of the "world") so it should really be a function.
(at a bare minimum it should be behind a deref as Ethan suggests but even that is somewhat poor practice IMO)
@allandaviesza just ran into this, so I wrote a quick hack for it