scittle

jmglov 2023-12-22T09:56:17.455889Z

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.

jmglov 2024-01-11T08:11:19.231839Z

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
borkdude 2023-12-22T09:58:25.469869Z

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

borkdude 2023-12-22T10:02:10.736669Z

hmm, httpkit?

borkdude 2023-12-22T10:03:41.300729Z

ah yes, httpkit is used here: https://github.com/babashka/sci.nrepl/blob/main/src/sci/nrepl/browser_server.clj

borkdude 2023-12-22T10:04:10.412889Z

does this happen with any evaluation or only with some?

borkdude 2023-12-22T10:04:14.246289Z

let me try

borkdude 2023-12-22T10:06:10.512579Z

yeah I can reproduce this, damnit.

😆 1
borkdude 2023-12-22T10:06:22.263599Z

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)

borkdude 2023-12-22T10:07:04.444939Z

looking into a fix

borkdude 2023-12-22T10:14:20.197259Z

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

borkdude 2023-12-22T10:14:38.121949Z

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

borkdude 2023-12-22T10:15:47.168449Z

ah ok got it working

borkdude 2023-12-22T10:16:02.018699Z

cider-connect-cljs and then select nbb

borkdude 2023-12-22T10:23:40.496509Z

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

borkdude 2023-12-22T10:26:58.528739Z

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

borkdude 2023-12-22T10:36:21.243329Z

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

borkdude 2023-12-22T10:36:58.912139Z

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

borkdude 2023-12-22T10:37:40.679469Z

Perhaps you can try that one @jmglov? https://github.com/babashka/sci.nrepl/commit/2c3c18ebda189ae54fb2b3294b1f5ca609ed1b96

borkdude 2023-12-22T10:37:50.293949Z

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

borkdude 2023-12-22T10:54:32.594159Z

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

🫠 1
borkdude 2023-12-22T11:06:17.522469Z

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...

borkdude 2023-12-22T11:12:17.364589Z

In Calva / VSCode it does work: 🤷

borkdude 2023-12-22T11:16:54.701379Z

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

borkdude 2023-12-22T11:17:07.159469Z

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

Benjamin 2023-12-22T12:38:35.578929Z

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

Benjamin 2023-12-22T12:40:54.685089Z

example sci.nrepl deps:

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

borkdude 2023-12-22T12:42:40.996559Z

@benjamin.schwerdtner I used bb dev in this directory which uses 0.6.15: https://github.com/babashka/scittle/blob/main/doc/nrepl/index.html

borkdude 2023-12-22T12:43:34.861069Z

same deps are you

borkdude 2023-12-22T12:44:55.956409Z

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

Benjamin 2023-12-22T12:45:04.307359Z

can cider-connect-clj works for me

borkdude 2023-12-22T12:45:17.148239Z

ok let me try again

Benjamin 2023-12-22T12:45:22.919109Z

using the cider patch I made

borkdude 2023-12-22T12:45:41.051829Z

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

Benjamin 2023-12-22T12:45:45.195799Z

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

Benjamin 2023-12-22T12:45:49.117149Z

yes

borkdude 2023-12-22T12:45:52.146699Z

ok, I'm going to try now

Benjamin 2023-12-22T12:46:28.951519Z

if cider hangs ctrl-g lol

borkdude 2023-12-22T12:46:44.715939Z

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

borkdude 2023-12-22T12:48:01.355429Z

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)

borkdude 2023-12-22T12:48:26.653849Z

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

Benjamin 2023-12-22T12:48:51.279049Z

I am surprised

borkdude 2023-12-22T12:49:09.906539Z

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

borkdude 2023-12-22T12:49:21.398559Z

except in-buffer eval

borkdude 2023-12-22T12:49:27.764369Z

fucking hell, this is brittle stuff

Benjamin 2023-12-22T12:49:35.880799Z

hm that sounds like multiple issues

borkdude 2023-12-22T12:49:55.104089Z

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

borkdude 2023-12-22T12:51:40.385189Z

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

borkdude 2023-12-22T12:53:02.254459Z

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

Benjamin 2023-12-22T12:53:03.712079Z

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

borkdude 2023-12-22T12:53:17.613529Z

yeah

Benjamin 2023-12-22T12:53:45.078589Z

I am on 25c51fd4b1246801ba3fa15c57b44d860772417c cider master

borkdude 2023-12-22T12:54:10.015679Z

I don't know why the heck we assoc the context here and in several other places: https://github.com/babashka/scittle/blob/9791c281e32bc11029ac6c99418045fba355596f/src/scittle/nrepl.cljs#L65

borkdude 2023-12-22T12:54:57.785469Z

but even when I dissoc-ed it here https://github.com/babashka/scittle/blob/main/src/scittle/nrepl.cljs#L14-L17 it didn't completely work

borkdude 2023-12-22T12:55:52.367409Z

upgrading CIDER didn't help

borkdude 2023-12-22T13:00:10.547639Z

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

Benjamin 2023-12-22T13:00:35.526699Z

yes. I can reproduce by sending a random request

Benjamin 2023-12-22T13:01:36.264539Z

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

borkdude 2023-12-22T13:02:04.438169Z

indeed

borkdude 2023-12-22T13:02:44.669589Z

I can push that change and test if it helps locally

Benjamin 2023-12-22T13:04:06.175569Z

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

borkdude 2023-12-22T13:04:47.486929Z

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

borkdude 2023-12-22T13:05:00.599649Z

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

borkdude 2023-12-22T13:05:25.942069Z

http://localhost:1341/nrepl.html

borkdude 2023-12-22T13:05:47.331799Z

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

borkdude 2023-12-22T13:06:24.498289Z

cider-connect-clj is still completely stuck for me

borkdude 2023-12-22T13:06:48.005209Z

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

borkdude 2023-12-22T13:07:07.479259Z

pushed to main

borkdude 2023-12-22T13:08:13.735189Z

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

borkdude 2023-12-22T13:09:14.801259Z

it seems CIDER is asking for op version

borkdude 2023-12-22T13:09:28.098739Z

emacs still completely stuck for me

borkdude 2023-12-22T13:09:41.889509Z

no errors in the server however

Benjamin 2023-12-22T13:12:30.273249Z

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

Benjamin 2023-12-22T13:13:23.418139Z

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

borkdude 2023-12-22T13:13:50.560839Z

is that any different than what I pushed?

Benjamin 2023-12-22T13:15:00.445669Z

no its the same

Benjamin 2023-12-22T13:15:20.604859Z

wait

Benjamin 2023-12-22T13:16:33.036499Z

I swapped the message to be the first arg

Benjamin 2023-12-22T13:18:26.140659Z

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.

borkdude 2023-12-22T13:18:54.359739Z

pushed the swapped args

borkdude 2023-12-22T13:19:02.749609Z

I'll test again

👀 1
borkdude 2023-12-22T13:20:30.197749Z

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

borkdude 2023-12-22T13:21:39.691789Z

perhaps it's refactor-nrepl or so

borkdude 2023-12-22T13:21:56.605969Z

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

Benjamin 2023-12-22T13:22:52.839389Z

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

borkdude 2023-12-22T13:23:10.660569Z

: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\"}"

borkdude 2023-12-22T13:23:27.327279Z

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

borkdude 2023-12-22T13:24:07.256029Z

1.13.0-SNAPSHOT it says with cider-version

Benjamin 2023-12-22T13:24:42.073769Z

hm me too

Benjamin 2023-12-22T13:24:48.099739Z

don't know what prefix-rewriting is

borkdude 2023-12-22T13:25:28.235219Z

me neither

Benjamin 2023-12-22T13:25:47.897869Z

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

borkdude 2023-12-22T13:25:56.340929Z

yes

borkdude 2023-12-22T13:28:09.050249Z

https://grep.app/search?q=prefix-rewriting%20

borkdude 2023-12-22T13:28:18.197489Z

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

borkdude 2023-12-22T13:28:44.802759Z

maybe I should just uninstall that package?

borkdude 2023-12-22T13:29:06.887499Z

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

Benjamin 2023-12-22T13:30:24.890459Z

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

borkdude 2023-12-22T13:30:57.857799Z

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

borkdude 2023-12-22T13:31:23.066539Z

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

borkdude 2023-12-22T13:32:11.043509Z

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

Benjamin 2023-12-22T13:32:16.799209Z

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

borkdude 2023-12-22T13:32:17.590239Z

instead of clojurescript-mode

Benjamin 2023-12-22T13:32:23.179869Z

hm

borkdude 2023-12-22T13:32:42.549759Z

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

borkdude 2023-12-22T13:33:07.286349Z

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

Benjamin 2023-12-22T13:34:08.313809Z

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

borkdude 2023-12-22T13:34:34.164199Z

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

Benjamin 2023-12-22T13:34:47.989779Z

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

Benjamin 2023-12-22T13:34:58.627499Z

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

borkdude 2023-12-22T13:35:12.802329Z

ok

Benjamin 2023-12-22T13:35:33.141519Z

with this yes: https://github.com/clojure-emacs/cider/pull/3600

borkdude 2023-12-22T13:35:44.188339Z

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

😅 1
Benjamin 2023-12-22T13:37:31.318359Z

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

borkdude 2023-12-22T13:40:41.906679Z

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

borkdude 2023-12-22T13:42:18.021789Z

ah yes, now it works

borkdude 2023-12-22T13:42:43.967509Z

👍

Benjamin 2023-12-22T13:42:55.513949Z

😄

borkdude 2023-12-22T13:44:04.140259Z

and even auto-complete is working 😎

borkdude 2023-12-22T13:44:49.337769Z

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

Benjamin 2023-12-22T13:48:03.408749Z

that auto complete inside scittle is such a win

jmglov 2023-12-22T20:29:39.181119Z

Holy moly what did I start in here? 😅

jmglov 2023-12-22T20:32:18.370259Z

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.

jmglov 2023-12-22T20:33:29.148359Z

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

borkdude 2023-12-22T20:33:50.016289Z

Have fun during your holidays!

🎉 1
jmglov 2023-12-30T13:39:04.074639Z

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.

borkdude 2023-12-30T13:50:47.900769Z

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

borkdude 2023-12-30T13:51:07.515399Z

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

Benjamin 2023-12-30T13:58:41.150679Z

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. @vemv 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

vemv 2023-12-30T15:07:49.575779Z

No hurry from our side