This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2021-02-05
Channels
- # announcements (16)
- # babashka (10)
- # beginners (80)
- # calva (18)
- # cider (10)
- # clojure (96)
- # clojure-austin (1)
- # clojure-europe (52)
- # clojure-france (6)
- # clojure-germany (2)
- # clojure-italy (4)
- # clojure-nl (4)
- # clojure-seattle (3)
- # clojure-spec (4)
- # clojure-uk (25)
- # clojurescript (97)
- # community-development (2)
- # cursive (7)
- # datomic (13)
- # figwheel-main (5)
- # fulcro (13)
- # inf-clojure (1)
- # jobs (3)
- # off-topic (33)
- # pathom (10)
- # polylith (8)
- # re-frame (7)
- # reitit (8)
- # releases (1)
- # reveal (2)
- # ring (4)
- # ring-swagger (1)
- # sci (6)
- # shadow-cljs (102)
- # slack-help (1)
- # spacemacs (28)
- # tools-deps (9)
- # vim (1)
- # xtdb (3)
Do you want keyword definition look-up and stuff? Time to upgrade Calva, because v2.0.160 has these changes: • https://github.com/clojure-lsp/clojure-lsp/releases/tag/2021.02.05-03.05.34 • https://github.com/BetterThanTomorrow/calva/issues/1016

Hey everyone, can I get a recommendation for either a Calva doc page or some other reference material? I'm pretty new to Clojure and the REPL in general. So far I've used Calva for faily basic stuff: cd into project, start repl, develop, etc. I've heard, however, that you can jack in to running REPL processes. This could be used to diagnose or do hotfixes to a production app. Another use case for jacking in to a remote REPL is for apps which are hosted in a VM (Docker, Vagrant, etc.). So ... uh, where do I start if I want to do something like that 😅
Check this out: https://github.com/clojure/tools.nrepl#embedding-nrepl-starting-a-server You can embed an nrepl server in your application. Say it's a web server backend/api - you can run an embedded nrepl server, and then when it's running, you can use the host:<port-you-started-embedded-nrepl-server-on> with Calva's connect command to connect to it. Then you are inside your running web backend/api. You can require namespaces from it, redefine an endpoint handler, etc.
@U01HMCQMBKP Something else to consider: any Clojure process can start a Socket REPL at startup just by specifying a JVM option -- which means you do not need any code or dependencies in your process at all -- and then you can connect to that socket server via telnet
, nc
(netcat), or from your editor if you use a plugin that understands plain socket REPLs (Clover for VS Code, Chlorine for Atom). Calva cannot currently connect to a socket REPL though.
We run socket REPLs in many of our processes, even in production, because all it needs is a JVM option at startup...
(at some point, nREPL should be able to be "side-loaded" over a socket REPL, and then Calva could use that approach to connect to a socket REPL and "upgrade" it)
To give you an example usage, clojure-lsp, which Calva runs to provide some language features, starts an embedded nrepl server: https://github.com/clojure-lsp/clojure-lsp/blob/ca37bfff980c1c4bc504527aeeebdd965e6c3a0a/src/clojure_lsp/nrepl.clj#L16
If we want to poke around in the running clojure-lsp program, we can run the Calva command "LSP Server Info", take the :port
value from the map returned, which is the nrepl server port, and use Calva's connect command to connect to it. Then we can navigate clojure-lsp's namespaces, check it's state, run functions ourselves to debug things, etc.
Speaking of, this :port
is now coming back as nil
@UKFSJSM38 😄. It was working a while back, and I see the nrepl code was moved around at some point lately.
yeah, this is on purpose, we only show the port if you compile it with lein with-profile debug bin
this is to reduce image size, (also it doesn't work for graalvm compiled images, which should be the default soon)
Great, thank you everybody! I think I've got a better grasp on what I need to do now:
1. embed nrepl into project
2. connect to repl
via Calva
3. ???
4. profit
#3. Run code to change/run project code
(require 'my-project.core)
(in-ns 'my-project.core)
(some-core-fn "test-args")
@app-state
It's not specific to Calva, really, but we have a Connect to a REPL command. What's important for Calva then is that the host program has an nrepl server running, and even better if it has cider-nrepl middleware loaded.
Dear Calva friends. The Calva team just started AMA:s at both ClojureVerse and Reddit. Please feel invited! • Reddit: https://www.reddit.com/r/Clojure/comments/ldiafr/we_created_and_maintain_calva_ask_us_anything/ • ClojureVerse: https://clojureverse.org/t/we-created-and-maintain-calva-ask-us-anything/
