Fork me on GitHub
#cider
<
2021-01-31
>
bmaddy04:01:32

I'm trying to cider-connect-cljs with a running shadow-cljs repl. It connects and the repl works great. However, when I try to cider-switch-to-repl-buffer in a cljs file in my project, I get this:

user-error: No cljs REPLs in current session "ti/fulcro-rad-demo:localhost:9000"
I've almost always used the jack-in method in the past, so I suspect there's something simple I'm missing here. Does anyone know what it might be? (versions: emacs = 27.1, spacemacs = [email protected], cider = 1.1.0snapshot, shadow-cljs = 2.11.8)

dpsutton04:01:31

if you put your cursor in the cljs repl buffer and then back into your source buffer then cider-switch-to-repl-buffer does it work?

bmaddy04:01:42

Nope, it still doesn't work when I do that.

bmaddy04:01:59

I saw that issue in the scrollback (you posted it). I figured it didn't apply since I only have the one repl running (which I should have mentioned).

dpsutton04:01:23

ah ok. interesting. let me see if i can repro

dpsutton04:01:52

hmm. works for me.

dpsutton04:01:19

think you can put up a simple repro and create an issue? tinies thing possible

dpsutton04:01:29

and have you updated to most recent CIDER?

bmaddy04:01:54

I updated today.

dpsutton04:01:07

any chance you're dealing with docker stuff? is the shadow server local?

bmaddy04:01:12

Nope, no docker. I realized I haven't restarted emacs in a while...trying that.

👍 1
bmaddy04:01:07

No luck, same issue. I'm trying to play around with https://github.com/fulcrologic/fulcro-rad-demo. I've never used shadow before, but I could probably figure out how to set up a minimal cljs project. I doubt I'll get that done tonight though--it's getting late where I am.

bmaddy05:01:08

Here's a pretty minimal setup: https://github.com/bmaddy/minimal-shadow-cljs-nodejs I start it with yarn shadow-cljs watch app and then run/choose the following in emacs:

cider-connect-cljs
localhost
9000
shadow
node-repl
cider-switch-to-repl-buffer from the src/server/main.cljs file gives me this:
user-error: No cljs REPLs in current session "2021/minimal-shadow-cljs-nodejs:localhost:9000"

dpsutton05:01:27

ok. so i did two different ways: first way: cider-jack-in-clojurescript

1. cider-jack-in-clojurescript, choose shadow then the app build. run "node target/main.js" to get the repl up. When i was in the shadow-cljs.edn file i ran cider-switch-to-repl-buffer and was told there are no *clj* buffers. going to server/main.cljs and tried again and it worked.
The other way i tried:
npx shadow-cljs -d nrepl/nrepl:0.8.3 -d cider/piggieback:0.5.2 -d cider/cider-nrepl:0.25.8 server
npx shadow-cljs watch app # from another terminal
node target/main.js

cider-connect-cljs from main.cljs ns
cider-switch-to-repl-buffer
it worked
So i can get it to work both if i use cider-connect and also cider-jack-in. The one issue i can see that might be confusing is if your cursor (point) is in the shadow-cljs.edn file it complains that there are no clj buffers, as its assuming you want a clj repl (not cljs) when visiting an edn file. It really out to take the first available, or perhaps be smart enough that shadow is cljs really and just try that rather than the clj repl

dpsutton05:01:17

so i suspect you are running m-x cider-switch-to-repl-buffer from an edn file and not getting your repl. Have you tried from src/server/main.cljs?

bmaddy13:01:20

omg that worked! I'm shocked that you have to start three separate proceses. Thank you so much for your help, @dpsutton!

bmaddy04:02:42

It turns out I spoke too soon on this. The minimal node version worked for me, but when I tried to do it with the fulcro project using a browser repl, I still couldn't get the cljs window to associate with the cljs repl. I ended up finding two things that get it to work: 1. use the repl type shadow-select (not positive this was a requirement, but I'm tired of testing) 2. I was using evil-window-left/`evil-window-right` to switch between the cljs file and cljs repl, but that will not associate them. I had to be in the cljs repl and use cider-switch-to-last-clojure-buffer to make cider-switch-to-repl-buffer associate correctly.

dpsutton16:01:50

When running from the command line , thheller says the server is much faster. Then the watch command is far faster. So it’s kinda shadow that does or or two processes. As for node, there is always this process. You run the browser. That provides the js environment. It just feels different here but it’s not.

👍 1
thheller09:02:06

watch app will start an implicit server if none is running

thheller09:02:31

the benefit of separate server is that you can at any point stop and restart the watch without fully restarting the server

thheller09:02:14

but otherwise you can just use watch without a separate server too. it is just my workflow to only use server and then do the rest from the UI or REPL

dpsutton14:02:44

Thanks! I didn’t want to ping you and drag you into tooling centric discussions. That’s awesome you commented. Appreciated

bmaddy04:02:42

It turns out I spoke too soon on this. The minimal node version worked for me, but when I tried to do it with the fulcro project using a browser repl, I still couldn't get the cljs window to associate with the cljs repl. I ended up finding two things that get it to work: 1. use the repl type shadow-select (not positive this was a requirement, but I'm tired of testing) 2. I was using evil-window-left/`evil-window-right` to switch between the cljs file and cljs repl, but that will not associate them. I had to be in the cljs repl and use cider-switch-to-last-clojure-buffer to make cider-switch-to-repl-buffer associate correctly.