clojure-emacs / cider

The Clojure Interactive Development Environment that Rocks for Emacs
https://cider.mx
GNU General Public License v3.0
3.52k stars 643 forks source link

cider using scittle nREPL doesn't send forms to REPL #3716

Closed IrrenWirr closed 1 week ago

IrrenWirr commented 2 weeks ago

Expected behavior

Sending forms from .cljs buffer to the cider-repl... buffer using scittle's nREPL (directly inputing forms into cider-repl... buffer works fine)

M-x cider-eval-last-sexp expected to evaluate form or throwing an error

Actual behavior

Only a message echo "You can run the command ‘cider-eval-last-sexp’ with C-x C-e" without any information nor noticeable change.

Steps to reproduce the problem

setup scittle

git clone https://github.com/babashka/scittle cd scittle bb dev

output:

> clojure -M -m shadow.cljs.devtools.cli --force-spawn watch main 
Serving static assets at http://localhost:1341
nREPL server started on port 1339...
Websocket server started on 1340...

open in browser

http://localhost:1341/nrepl.html

open in emacs

emacs -Q M-x package-install cider goto "./resources/public/cljs/nrepl_playground.cljs" file M-x cider-connect-cljs host 127.0.0.1 port 1339 custom (+ 2 3)

M-x cider-eval-last-sexp somewhere in "nrepl_playground.cljs"

Environment & Version information

CIDER version information

;; Connected to nREPL server - nrepl://127.0.0.1:1339
;; CIDER 1.15.0 (Cogne)

scittle version

scittle v0.6.17

Emacs version

GNU Emacs 30.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version 3.24.41, cairo version 1.18.0)

Operating system

Guix

Picture

image

IrrenWirr commented 2 weeks ago

but works fine when using M-x cider-connect-clj instead of M-x cider-connect-cljs

maybe not a bug?

vemv commented 2 weeks ago

Hi @IrrenWirr , thanks a lot for the precise issue report.

Under your setup, what's the value of (cider-runtime)? It should return scittle - if it doesn't, that would likely have to do.

IrrenWirr commented 2 weeks ago

On buffer *cider-repl...* M-: (cider-runtime) => scittle

On buffer ...playground-cljs M-: (cider-runtime)=>

Debugger entered--Lisp error: (wrong-type-argument stringp nil)
  cider--clojure-version()
  cider-runtime()
  eval((cider-runtime) t)
  #f(compiled-function () #<bytecode -0x149634791cd8399e>)()
  #f(compiled-function () #<bytecode -0x5db3e1955cb81d1>)()
  eval-expression((cider-runtime) nil nil 127)
  funcall-interactively(eval-expression (cider-runtime) nil nil 127)
  command-execute(eval-expression)
vemv commented 2 weeks ago

What does (cider-current-repl) return in the nrepl_playground.cljs file?

IrrenWirr commented 2 weeks ago

What does (cider-current-repl) return in the nrepl_playground.cljs file?

nil.

But I see something that wasn't visible on initial report, sry, nrepl_playground.cljs buffer line has cider[not connected]. Screenshot_2024-06-23_22-18-43

IrrenWirr commented 2 weeks ago

also, cannot either do M-x cider-connect-sibling-cljs on nrepl_playground.cljs

=> cider--no-repls-user-error: No clj or cljs REPLs in current session "dev/scittle:127.0.0.1:1339"

and creating a new session with M-x cider-connect-cljs on nrepl_playground.cljs : just create a new cider-nrepl without chaning the cider[not connected] status of nrepl_playground.cljs

vemv commented 2 weeks ago

Thanks!

Can you eval (cider-debug-sesman-friendly-session-p) within the same file? I'd need to inspect its output

IrrenWirr commented 2 weeks ago

Thanks!

Can you eval (cider-debug-sesman-friendly-session-p) within the same file? I'd need to inspect its output

"((\"/home/irrenwirr/dev/scittle/resources/public/cljs/nrepl_playground.cljs\" \"was not determined to belong to classpath:\" nil \"or classpath-roots:\" nil) (\"/home/irrenwirr/dev/scittle/resources/public/cljs/nrepl_playground.cljs\" \"was not determined to belong to classpath:\" nil \"or classpath-roots:\" nil))"
vemv commented 2 weeks ago

Perfect, that's the problem - the scittle runtime is returning an empty classpath. That foils our logic.

I think that there was a similar issue for bb or nbb and that it got fixed after some heads up.

I've pinged over Clojurians https://clojurians.slack.com/archives/C034FQN490E/p1719174846304749

vemv commented 2 weeks ago

In principle, scittle doesn't have the notion of a classpath, so there isn't a short-term fix.

You can sesman-link-with-buffer instead. Then https://github.com/clojure-emacs/cider/issues/3716#issuecomment-2185311212 as well as your original issue should start working properly.

IrrenWirr commented 1 week ago

In principle, scittle doesn't have the notion of a classpath, so there isn't a short-term fix.

You can sesman-link-with-buffer instead. Then #3716 (comment) as well as your original issue should start working properly.

Nop, cider-connect-cljs + sesman-link-with-buffer still doesn't fix the issue on my end.

But simply using cider-connect-clj (instead of -cljs) works without issues, even while using clojurescript-mode. This one is a good workaround :)

vemv commented 1 week ago

Nice!

For this working session, what does (cider-debug-sesman-friendly-session-p) return?

IrrenWirr commented 1 week ago

Nice!

For this working session, what does (cider-debug-sesman-friendly-session-p) return?

(("/home/irrenwirr/dev/scittle/resources/public/cljs/nrepl_playground.cljs" "was not determined to belong to classpath:" nil "or classpath-roots:" nil))
"((\"/home/irrenwirr/dev/scittle/resources/public/cljs/nrepl_playground.cljs\" \"was not determined to belong to classpath:\" nil \"or classpath-roots:\" nil))"

but works fine Screenshot_2024-06-24_17-56-11

vemv commented 1 week ago

Thanks.

Happy that we documented a workaround and likely root cause.

I'll close the issue, but anyone interested could further investigate.