Fork me on GitHub
#scittle
<
2023-12-22
>
jmglov09:12:17

I'm trying to connect to scittle with CIDER following the exact instructions in https://github.com/babashka/scittle/tree/main/doc/nrepl, and am getting an exception:

Fri Dec 22 10:49:58 CET 2023 [worker-1] ERROR - handle websocket frame org.httpkit.server.Frame$TextFrame@53da070f                                                                             
java.lang.RuntimeException: No reader function for tag object                                                                                                                                  
Does anyone have any idea what might be going wrong here? I added the elisp snippet as directed.

borkdude09:12:25

don't know, what CIDER version are you using? at one point it worked for sure :)

borkdude10:12:10

hmm, httpkit?

borkdude10:12:10

does this happen with any evaluation or only with some?

borkdude10:12:10

yeah I can reproduce this, damnit.

😆 1
borkdude10:12:22

at clojure.edn$read_string.invokeStatic(edn.clj:46)
	at clojure.edn$read_string.invokeStatic(edn.clj:37)
	at clojure.edn$read_string.invoke(edn.clj:37)

borkdude10:12:04

looking into a fix

borkdude10:12:20

I'm using the newest sci.nrepl commit now and can't repro this but nothing happens either

borkdude10:12:38

this is either CIDER bitrot or scittle nrepl bitrot... aaaaargh

borkdude10:12:47

ah ok got it working

borkdude10:12:02

cider-connect-cljs and then select nbb

borkdude10:12:40

I see, the scittle/doc/nrepl stuff was already at the latest commit, but locally I wasn't on the latest commit

borkdude10:12:58

there is some edn read issue, going to check what the hell this is now

borkdude10:12:21

It seems this commit at least broke something: https://github.com/babashka/sci.nrepl/commit/2f8a9ed2d39a1b09d2b4d34d95494b56468f4a23 cc @U02CV2P4J6S And something else changed in CIDER I think because in the REPL window I can evaluate, but not from the buffer.

borkdude10:12:58

I reverted the handling of unknown nREPL ops to send

(send-response (assoc ctx :response {"status" #{"error" "unknown-op" "done"}}))
This seems to at least fix the EDN serialization error

borkdude10:12:50

about the in-buffer evaluation: don't know yet

borkdude10:12:32

I don't know what changed in CIDER but this is pretty frustrating

1
borkdude11:12:17

I might have a look at this later but right now I'm not in the mood to force-quit my emacs every time I try something...

borkdude11:12:17

In Calva / VSCode it does work: 🤷

borkdude11:12:54

Yeah, everything just works without any changes in Calva / VScode

borkdude11:12:07

So something in CIDER probably changed, don't know what.

Benjamin12:12:35

please use scittle 0.6.15 https://github.com/babashka/scittle/releases/tag/v0.6.15 Also, when you did jack in clj, it didn't count as cljs currently, fix: https://github.com/clojure-emacs/cider/pull/3600 I suspect if you say connect cljs -> nbb its a workaround for the second issue right now. Cider hanging is probably because the scittle version is old. The current sci.nrepl implementation asks the scittle server for "describe". It was sort of a breaking change we thought would be tolerable, but yea

Benjamin12:12:54

example sci.nrepl deps:

:deps
 {sci.nrepl/sci.nrepl
  {:git/sha "2f8a9ed2d39a1b09d2b4d34d95494b56468f4a23"
   :git/url ""}}

borkdude12:12:34

same deps are you

borkdude12:12:55

@U02CV2P4J6S thanks for looking into this ❤️ does it work for you at all right now?

Benjamin12:12:04

can cider-connect-clj works for me

borkdude12:12:17

ok let me try again

Benjamin12:12:22

using the cider patch I made

borkdude12:12:41

ok, but when choosing nbb this shouldn't matter without your patch, correct?

Benjamin12:12:45

else cider-connect-cljs -> nbb works as a workaround

borkdude12:12:52

ok, I'm going to try now

Benjamin12:12:28

if cider hangs ctrl-g lol

borkdude12:12:44

I'm running:

borkdude@m1 ~/dev/scittle/doc/nrepl (main) $ bb dev
Serving static assets at 
Websocket server started on 1340...
nREPL server started on port 1339...
I'm going to open the web page and then do the connect sequence in emacs

borkdude12:12:01

I am getting:

Fri Dec 22 13:47:16 CET 2023 [] ERROR - handle websocket frame org.httpkit.server.Frame$TextFrame@53d31621
java.lang.RuntimeException: No reader function for tag object
	at clojure.lang.EdnReader$TaggedReader.readTagged(EdnReader.java:801)
in the server (like in the OP) and emacs hangs. I didn't get any choices after doing cider-connect-clj (this is why I did cider-connect-cljs before)

borkdude12:12:26

ctrl-g doesn't work, only force quit (😡 )

Benjamin12:12:51

I am surprised

borkdude12:12:09

hahaha, after force quit, I get a popup from emacs if I want to save a file. when I then say no, then it works

borkdude12:12:21

except in-buffer eval

borkdude12:12:27

fucking hell, this is brittle stuff

Benjamin12:12:35

hm that sounds like multiple issues

borkdude12:12:55

let me upgrade cider so I'm at least on the same version as you

borkdude12:12:40

yes, the EDN read issue is caused by the SCI context being part of the EDN response, which should be left out. I'm surprised this doesn't cause an issue with VSCode. It seems to happen when the version is requested by CIDER, an op which isn't implemented

borkdude12:12:02

I'm going to upgrade to cider 20231204.843 available melpa Clojure Interactive Development Environment that Rocks

Benjamin12:12:03

Ah. so we try to edn print some function hence the error

Benjamin12:12:45

I am on 25c51fd4b1246801ba3fa15c57b44d860772417c cider master

borkdude12:12:52

upgrading CIDER didn't help

borkdude13:12:10

@U02CV2P4J6S I think the context accidentally becomes part of the response on an unknown/unsupported nREPL op: https://github.com/babashka/scittle/commit/95740162d42bf4c9a2a17740c4eed07b0899229d

Benjamin13:12:35

yes. I can reproduce by sending a random request

Benjamin13:12:36

nrepl.cljs line 71 should not add the ctx to the response I suppose

borkdude13:12:44

I can push that change and test if it helps locally

Benjamin13:12:06

I forgot how to dev scittle. Want a repl to see what ctx does and where session and id should come from

borkdude13:12:47

here is how you can do it. in the root of the project, run bb dev

borkdude13:12:00

and then visit localhost:.../nrepl.html

borkdude13:12:47

and then I open the doc/nrepl/playground.cljs file to evaluate something

borkdude13:12:24

cider-connect-clj is still completely stuck for me

borkdude13:12:48

but no edn read errors, so I'm going to push that change

borkdude13:12:07

pushed to main

borkdude13:12:13

I guess why vscode/calva works and emacs doesn't (before at least) is that nrepl should actually never try an op that isn't present in describe

borkdude13:12:14

it seems CIDER is asking for op version

borkdude13:12:28

emacs still completely stuck for me

borkdude13:12:41

no errors in the server however

Benjamin13:12:30

(nrepl-reply msg (merge msg {:status ["error" "done"] :err "unkown-op"}))
this seems correct and seems to work

Benjamin13:12:23

with this I can send a random req and get an error without issue

borkdude13:12:50

is that any different than what I pushed?

Benjamin13:12:00

no its the same

Benjamin13:12:33

I swapped the message to be the first arg

Benjamin13:12:26

this fixes cider making emacs stuck and the parse edn error afaik. So there is some remaining issue where cider asks for version but shouldn't? I think on my end it does 'describe' and it turns out good.

borkdude13:12:54

pushed the swapped args

borkdude13:12:02

I'll test again

👀 1
borkdude13:12:30

that fixes the freezing, I'm getting this though:

borkdude13:12:39

perhaps it's refactor-nrepl or so

borkdude13:12:56

cider-connect-cljs works only in REPL, not from buffer

Benjamin13:12:52

wondering what commit this is in cider that you use. Is that v1.12.0 tag?

borkdude13:12:10

:msg "{:prefix-rewriting \"false\", :ns \"nrepl-playground\", :err \"unkown-op\", :debug \"false\", :op :version, :insert-newline-after-require \"true\", :status [\"error\" \"done\"], :id \"5\", :session \"df085b44-b02d-4773-9d4f-3da662f225dd\"}"

borkdude13:12:27

I have no fucking clue, I'm just using the new cider.el from melpa

borkdude13:12:07

1.13.0-SNAPSHOT it says with cider-version

Benjamin13:12:48

don't know what prefix-rewriting is

Benjamin13:12:47

ah the issue is it asks for op "version" and doesn't handle that it comes back with an error maybe

borkdude13:12:18

it seems I have some old refactor-nrepl crap going on here

borkdude13:12:44

maybe I should just uninstall that package?

borkdude13:12:06

but nonetheless, the cider should just work since people might have installed it

Benjamin13:12:24

somewhere somebody asks for "version" and that is not right, they get an error back. its not on the default latest cider by default. But its annoying that cider doesn't truck along after an error

borkdude13:12:57

I de-installed clj-refactor and this error went away

borkdude13:12:23

but it ends up in namespace nil now and I still can't evaluate from the buffer, at least not with cider-connect-clj

borkdude13:12:11

oh it does work when I switch to clojure-mode facepalm

Benjamin13:12:16

the connection doesn't count as cljs so I expect that. that is the fix I pushed

borkdude13:12:17

instead of clojurescript-mode

borkdude13:12:42

but I don't even get the list of choices with connect-clj, I get the list of choices with connect-cljs

borkdude13:12:07

@U054AT6KT do you have clj-refactor installed in emacs? you could try without it and maybe that fixes it for you

Benjamin13:12:08

connect-clj is 1 dimensional. connect-cljs has a second dimension of cljs-type

borkdude13:12:34

ok, I'm fine with that, but you mentioned connect-clj before, this is why I tried it

Benjamin13:12:47

With my fix connect-clj should say this is scittle hence a cljs repl.

Benjamin13:12:58

Yea.. connect-clj is great whe it is not broken

borkdude13:12:44

well, it's somewhat less broken for me now after de-installing clj-refactor but not optimal. Calva works though

😅 1
Benjamin13:12:31

if you say connect cljs and nbb, it should also work. Unless my mental model is wrong.

borkdude13:12:41

it should work, but I still can't eval from a buffer

borkdude13:12:18

ah yes, now it works

borkdude13:12:04

and even auto-complete is working 😎

borkdude13:12:49

the clj-refactor package still interferes somehow, might be something to check up on

Benjamin13:12:03

that auto complete inside scittle is such a win

jmglov20:12:39

Holy moly what did I start in here? 😅

jmglov20:12:18

I resorted to just using my cider-repl buffer, which worked after a few whacks on C-g. Couldn’t eval stuff from my code buffers, but I was at least able to REPL my browser.

jmglov20:12:29

I’m heading out on holiday now, but I’ll try some of the stuff in this thread if I get a chance.

borkdude20:12:50

Have fun during your holidays!

🎉 1
jmglov13:12:04

Using the nbb CLJS REPL type does work for me, but CIDER still doesn't understand that my buffer is connected to that REPL, so I still have to resort to typing stuff into the REPL buffer directly. This is using CIDER 1.12.0 and uninstalling clj-refactor.

borkdude13:12:47

@U054AT6KT does it help if you switch to clojure-mode or clojurescript-mode?

borkdude13:12:07

I remember I sometimes I had to switch to clojure-mode to make it work

Benjamin13:12:41

depends on the output of cider-repls. I suppose that also has to do with the current mode. Hm; I thought cljs -> nbb should be a workaround 'till the scittle == cljs fix. @U45T93RA6 https://github.com/clojure-emacs/cider/pull/3600 this is the context for the pull request. I'm not getting to cleaning it up currently

vemv15:12:49

No hurry from our side

jmglov08:01:19

Just a follow-up on this: somehow the REPL works connected to my buffer! I have no clue what combination of eldritch ceremonies accomplished this, but I'm happily Scittling along and will be posting a blog thingy in the next couple of days about my misadventures. 😉

🎉 1