This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-11-16
Channels
- # announcements (7)
- # babashka (8)
- # beginners (48)
- # calva (4)
- # cider (6)
- # circleci (2)
- # clj-commons (14)
- # clj-kondo (3)
- # clj-on-windows (7)
- # cljs-dev (34)
- # clojure (49)
- # clojure-dev (25)
- # clojure-europe (48)
- # clojure-losangeles (1)
- # clojure-nl (4)
- # clojure-norway (33)
- # clojure-uk (2)
- # clojurescript (37)
- # community-development (5)
- # conjure (17)
- # cursive (2)
- # data-science (1)
- # editors (10)
- # emacs (50)
- # events (22)
- # honeysql (11)
- # introduce-yourself (1)
- # jobs-discuss (13)
- # lsp (42)
- # malli (9)
- # off-topic (7)
- # pathom (11)
- # portal (5)
- # re-frame (3)
- # reagent (22)
- # reitit (8)
- # reveal (1)
- # rewrite-clj (4)
- # shadow-cljs (38)
- # xtdb (21)
How does one start a REPL to connect to when project is using tools.deps?
I think when I write clj
it doesn't have nREPL middleware
I'd recommend either vim-jack-in to start a tools.deps REPL with an nREPL connection OR go through the nREPL / cider documentation websites, they have a bunch of examples of config and one liners that start an nREPL.
The CIDER website / documentation is probably the best one since it include nREPL and the CIDER middleware.
I have several aliases in the user level configuration for starting a Repl via the command line (which I start before opening a Clojure file in Conjure)
https://github.com/practicalli/clojure-deps-edn#repl-terminal-ui
In basic terms, include the nrepl library as a dependency and call nrepl. Cider middleware is also required for full Repl support when using Conjure.
So for a headless terminal Repl, run clojure -M:repl/headless
;; Simple nREPL server REPL with Cider & Conjure support, headless
:repl/headless
{:extra-deps {nrepl/nrepl {:mvn/version "1.0.0"}
cider/cider-nrepl {:mvn/version "0.28.5"}}
:main-opts ["-m" "nrepl.cmdline"
"--middleware" "[cider.nrepl/cider-middleware]"]}
Or if Repl prompt is required
:repl/interactive
{:extra-deps {nrepl/nrepl {:mvn/version "1.0.0"}
cider/cider-nrepl {:mvn/version "0.28.5"}}
:main-opts ["-m" "nrepl.cmdline"
"--middleware" "[cider.nrepl/cider-middleware]"
"--interactive"]}
Thanks. This was exactly what I was asking about (didn't test but I already have this setup with Leiningen). I'd like to have this pasted into the README of Conjure so that there wouldn't be a need to look for it.
Ah, this was what I was looking for: https://github.com/Olical/conjure/wiki/Quick-start:-Clojure#with-clojure-cli I didn't want to delve too much into how tools.deps works, I wanted to run it and figure out later.
Leiningen has nREPL built in, so its always there when using lein repl
Clojure CLI (tools.deps) is a lot more possible options even for starting a REPL process, (socket, prepl, nrepl, etc) so does not provide anything by default.
Why would one want a non-interactive REPL? I think that even if I connect to it from a tool like Conjure I still want to have it as interactive because it helps to debug if it's the REPL that hangs or the editor. The only place where I would be ok with non-interactive REPL is on some kind of deployment where I'll have to connect to REPL. But even then I'd probably want to use interactive too. I don't understand why you have both configs in your user config. Do you even use non-interactive one?
I just keep a shell script in ~/bin/repl
. I might have more specialized ones in project directories, that maybe export some env vars or set up different tools.deps aliases:
#!/usr/bin/env bash
clj -Sdeps '{:deps {nrepl/nrepl {:mvn/version "RELEASE"} cider/cider-nrepl {:mvn/version "RELEASE"}}}' -M -m nrepl.cmdline --middleware '[cider.nrepl/cider-middleware]' --interactive --color
Ah, but that's skips leiningen then :thinking_face:
This reminds me, I should update the deps versions in the Conjure quickstart examples…
I use https://github.com/walterl/dotfiles/blob/master/_config/nvim/plugin/clj_jackin.vim`RunClj`https://github.com/walterl/dotfiles/blob/master/_config/nvim/plugin/clj_jackin.vim, which is a severely stripped down version of vim-jack-in's Clj
command. The main feature is that it does less, so you can take more control over things like :main-opts
via aliases in deps.edn
, to use the sweet solutions like those provided by @U05254DQM and @U08BW7V1V.