Hello everyone,
For those using Emacs/CIDER with Polylith projects, what's your setup process? I'm currently trying to configure my environment with (setq cider-clojure-cli-aliases "dev:test"), but I'm running into dependency resolution issues when evaluating code.
Has anyone successfully set up a Polylith workspace with CIDER? Any configuration tips or examples you could share would be greatly appreciated!
thanks!
I am using polylith with cider, I have the above variable set like this.
(clojure-mode . ((cider-clojure-cli-aliases . "-M:dev")
(cider-preferred-build-tool . clojure-cli)))
Also the thing I always forget is make sure your in a clj file inside the development folder, so that it reads your root deps.edn which should have all yours dependencies inside.;; Startup: /opt/homebrew/bin/clojure -Sdeps \{\:deps\ \{nrepl/nrepl\ \{\:mvn/version\ \"1.3.0\"\}\ cider/cider-nrepl\ \{\:mvn/version\ \"0.50.2\"\}\ refactor-nrepl/refactor-nrepl\ \{\:mvn/version\ \"3.10.0\"\}\}\ \:aliases\ \{\:cider/nrepl\ \{\:main-opts\ \[\"-m\"\ \"nrepl.cmdline\"\ \"--middleware\"\ \"\[refactor-nrepl.middleware/wrap-refactor\,cider.nrepl/cider-middleware\]\"\]\}\}\} -M:dev:test:cider/nrepl
@seancorfield it looks like this
And connect the cider to the REPL (`cider-connect-clj`) it looks to works as expected.
Okay, if starting the REPL manually (from the workspace root) and connecting to it directly works, then I suspect Oliver's comment about which file you have open when you try to jack-in is relevant here:
> Also the thing I always forget is make sure your in a clj file inside the development folder, so that it reads your root deps.edn which should have all yours dependencies inside.
Since every brick has deps.edn, I suspect if you jack-in while you have a component/base source file open, it will use that brick's deps.edn instead of the root deps.edn?
(and maybe there's a way to tell CIDER to use a specific project root folder instead?)
@seancorfield you're right, cider-jack-in from root deps.end works as expected.
I'm used to VS Code / Calva where it asks which folder is the project root when it thinks there are multiple options (because VS Code has the notion of "projects", which Emacs/CIDER does not). Glad you found a way to make it work.
I see. Thanks for the help
I always create a .dir-locals.el file in the project's root directory with the following content:
((nil . ((cider-clojure-cli-aliases . ":dev:test"))))
This allows me to start CIDER's REPL with the :dev and :test aliases from any file inside the Polylith project (notice the nil instead of clojure-mode).If you do C-u when you jack-in, you should get the whole command CIDER will use to start the REPL, what does that command look like?
Can you run it from the command-line directly and connect a different nREPL client to test against it? (`lein repl :connect` or whatever the syntax is, if you have Leiningen installed, else maybe the latest version of Rebel Readline which now has an nREPL client)
yeah that caught me out for a while, I wonder if there is a way to configure it with .dir-locals to set the deps it will use, I always jack into to a file with in the development folder now as that should have all dependencies for all bases and components