Closed
Description
Expected behavior
I expect to be able to send expressions from a .cljs file in clojurescript-mode to an nbb nrepl server.
Actual behavior
Nothing happens until I activate clojure-mode in a .cljs file.
Steps to reproduce the problem
npm install -g nbb
nbb nrepl-server :port 1338
Then cider-connect from emacs to that server and try to evaluate some expressions from a .cljs file:
foo.cljs:
(defn version []
js/process.version)
(version)
(require '["fs" :as fs])
(fs/existsSync "README.md")
(fs/existsSync "README2.md")
(require '[clojure.string :as str])
(first (str/split js/process.env.PATH ":"))Environment & Version information
CIDER version information
Include here the version string displayed when
CIDER's REPL is launched. Here's an example:
;; Connected to nREPL server - nrepl://localhost:1337
;; CIDER 1.2.0snapshot (package: 20210914.1315)
Emacs version
27.2
Operating system
macOS
Activity
bbatsov commentedon Oct 2, 2021
Do you have the same problem with
cider-connect-cljs? I'm guess "yes" as this still assumes the Clojure nREPL server, but I'm asking just in case.borkdude commentedon Oct 2, 2021
With
cider-connect-cljsit's the same + theclojure-modeworkaround doesn't work there.bbatsov commentedon Oct 2, 2021
Got it.
bbatsov commentedon Oct 29, 2021
I finally looked at this and the problem is that when you use
cider-connectthis is actuallycider-connect-clj, which sets the connection type automatically to Clojure. Then if you try to evaluate something from a cljs file CIDER is looking for a cljs REPL, which it can't find. That's why switching toclojure-modefixed this. I'll have to think a bit how to best approach this, but it shouldn't be hard to fix.I guess we'll have to add some simple detection that we're connected to
nbband just skip the regularcljsinit sequence (as for all other REPLs first we started a Clojure connection that gets upgraded to ClojureScript by evaluating a bit of "magic" code). Clearly, that's not need for a native ClojureScript REPL likenbb.borkdude commentedon Oct 30, 2021
Thanks for looking into this.
benjamin-asdf commentedon Jan 15, 2022
with cider
318fe6878d8bedf5db9dfa649dedb45d72b2e7eeI try
nbb nrepl-server :port 1338cider-connect-cljfalls back to reading from minibuffer
output from nbb server:
cider-repl contents:
And here is the stacktrace for the "List expression" read from minibuffer call (which feels like a bug in that situation)
vxe commentedon Mar 16, 2022
any updates?
bbatsov commentedon Mar 17, 2022
Had no time for this so far. The way things are going it's unlikely that I'll be able to tackle it before April/May. If someone wants to beat me to it - be my guest.
jackrusher commentedon Apr 30, 2022
(It's not just
nbb, btw. I also have some "connect directly to a clojurescript REPL" stuff happening that would benefit greatly from being able to evaluate forms while in CLJS mode.)borkdude commentedon Apr 30, 2022
@bbatsov I'm probably going to look into this next Monday/Tuesday. Any pointers that will set me on the right track will be appreciated. As
cider-connectis an alias forcider-connect-clj, where should we start? I assume we should supportcider-connect-cljsinstead? Or should we have acider-connect-genericalternative that doesn't assume anything but just plays by the rules of the nREPL "spec"?jackrusher commentedon May 1, 2022
Looking at the spec and a trace of an nREPL session between cider and a jack'd in JVM, it appears that cider wants a few non-standard ops and falls back to trying to execute JVM-specific code when they're absent. (For example, cider seems to want a
stacktraceop, and falls back to calling(clojure.stacktrace/print-cause-trace *e)directly if it isn't available.Should we discuss improving the protocol a bit?
borkdude commentedon May 1, 2022
I think this isn't a protocol problem, it's a problem of a client that expects the nREPL server to be of a certain implementation (JVM Clojure) rather than expecting it to just talk nREPL and implement the specification. Or maybe it is this way because the protocol isn't rich or specified/documented enough?
33 remaining items
Update default repl-requires
Update default repl-requires (clojure-emacs#3061)
Allow connecting to nbb via connect-clj (clojure-emacs#3061)
Allow connecting to nbb via connect-clj (clojure-emacs#3061)
Allow connecting to nbb via connect-clj (clojure-emacs#3061)
Allow connecting to nbb via connect-clj (clojure-emacs#3061)
Allow connecting to nbb via connect-clj (clojure-emacs#3061)
Allow connecting to nbb via connect-clj (#3061) (#3272)
vemv commentedon Sep 29, 2023
Is this issue still valid? I see commits at the bottom of the timeline so I'd guess not
cc/ @benjamin-asdf
benjamin-asdf commentedon Sep 29, 2023
@vemv No I wouild say this is fixed. Cider nbb support is quite complete as far as I am aware.
vemv commentedon Sep 29, 2023
Nice!
vxe commentedon Oct 1, 2023
nice work all, big achievement here
dmg46664 commentedon Oct 2, 2023
Confirmed I needed to remove the snippet. Nice one.