This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-10-14
Channels
- # announcements (9)
- # beginners (49)
- # calva (26)
- # cider (6)
- # clj-kondo (17)
- # cljsjs (1)
- # cljsrn (2)
- # clojure (72)
- # clojure-europe (5)
- # clojure-france (8)
- # clojure-greece (1)
- # clojure-italy (5)
- # clojure-nl (9)
- # clojure-spec (49)
- # clojure-uk (17)
- # clojuredesign-podcast (13)
- # clojurescript (137)
- # cursive (15)
- # data-science (1)
- # datomic (55)
- # duct (2)
- # emacs (5)
- # figwheel-main (11)
- # fulcro (11)
- # graphql (1)
- # hoplon (1)
- # instaparse (1)
- # jobs (12)
- # jobs-rus (1)
- # leiningen (1)
- # nrepl (34)
- # nyc (2)
- # off-topic (1)
- # onyx (1)
- # pedestal (1)
- # re-frame (6)
- # reitit (3)
- # remote-jobs (1)
- # shadow-cljs (196)
- # sim-testing (1)
- # spacemacs (9)
- # sql (1)
- # vim (70)
- # xtdb (31)
I’m having a problem implementing support for nrepl.edn
in Cursive, although I’m not sure if this is an nREPL problem or a piggieback one.
I thought I had implemented the support, but when I try to test piggieback, I get:
Connecting to local nREPL server...
nREPL server started on port 52466 on host 127.0.0.1
Clojure 1.10.1
(require 'cljs.repl.nashorn 'cider.piggieback)
=> nil
(cider.piggieback/cljs-repl (cljs.repl.nashorn/repl-env))
Execution error (IllegalStateException) at cider.piggieback/cljs-repl (piggieback_impl.clj:168).
Can't change/establish root binding of: *cljs-repl-env* with set
I found a couple of issues about this, but they were either about using very old versions of various things, or about using trampoline with leiningen.
I’m establishing my server like this:
`(do
(-> (File. ~(.getCanonicalPath init-file))
(.deleteOnExit))
(try (require 'nrepl.server 'nrepl.config 'nrepl.cmdline)
(catch Throwable t#
(println "Error loading nrepl.server:"
(or (.getMessage t#) (type t#)))))
(try
(let [config# (merge {:host "127.0.0.1"
:port 0}
nrepl.config/config)
{:keys [port# bind# handler# transport# greeting#]} (nrepl.cmdline/server-opts config#)
server# (nrepl.server/start-server
:port port#
:bind bind#
:ack-port ~ack-port
:handler handler#
:transport-fn transport#
:greeting-fn greeting#)
port# (:port server#)]
(println "nREPL server started on port" port# "on host 127.0.0.1"))
(catch Throwable t#
(println "Error starting server:"
(or (.getMessage t#) (type t#))))))
deps.edn:
{:deps {org.clojure/clojurescript {:mvn/version "1.10.520"}}
:aliases {:repl {:extra-deps {nrepl/nrepl {:mvn/version "0.6.0"}
cider/piggieback {:mvn/version "0.4.2"}}}}}
I’m not directly invoking nrepl.cmdline
for everything, but I am reusing most of its logic, in particular for creating the handler from the configured middleware.
Ok, one problem was that nrepl.edn
should have been .nrepl.edn
, so the middleware wasn’t being found. However even after fixing that I’m still having the same problem.
I’ve debugged this, and the piggieback middleware does seem to be being applied to the handler correctly, which means I’m pretty much out of ideas.
I’m going to try just calling nrepl.cmdline directly and passing the args as if I were calling -main, and see if I’m missing something subtle.
There’s not, but I guess it’s not a bad idea. 🙂 There a few pretty basic ops in cider-nrepl
, though - e.g. classpath
.
That definitely surprised me, as your code looked legit to me, but I’m glad to hear we didn’t break something. 😄
Yeah, it’s weird. I think I’ll continue just calling that directly, but it’s definitely odd.
I think I’ll just keep doing that so that Cursive will interop better with all the related nREPL tooling, and things like .nrepl.port
should just work.
I agree. I’d also welcome some feedback on the current state of the nrepl.cmdline
API, which I consider experimental at this point. Obviously without having clients of it around it was hard to assess if we got it right or not. 🙂
This is currently the extent of my use of it:
(try (require 'nrepl.cmdline)
(catch Throwable t#
(println "Error loading nREPL:"
(or (.getMessage t#) (type t#)))
(System/exit 1)))
(nrepl.cmdline/-main "--ack" ~(str ack-port))