scittle

chromalchemy 2024-12-16T19:36:11.127959Z

I am using the scittle nrepl setup with some success, but having an issue: With this bb.edn, I am able to use bb dev task to start the nrepl (relay) server. And if I jack into port 1339 in Calva, I am able to eval the cljs code from my editor. I also have the bb nrepl-eval task to evaluate a code (string) in scittle runtime from the command line. If I jack-in in Calva first, the nrepl-eval task works. But If i dont jack-in first, and try to use the bb task first, i get this error that symbols are unresolved: ex: bb nrepl-eval "(test-trace)"

"#error {:message \"Could not resolve symbol: test-trace\", :data {:type :sci/error, :line 1, :column 1, :message \"Could not resolve symbol: test-trace\", :sci.impl/callstack #object[cljs.core.Volatile {:val ({:line 1, :column 1, :ns #object[Tr user], :file nil})}], :file nil, :phase \"analysis\"}, :cause #error {:message \"Could not resolve symbol: test-trace\", :data {:type :sci/error, :line 1, :column 1, :file nil, :phase \"analysis\"}}}"
I assumed that the scittle file ns is loded on js webpage startup. I get printouts from code in devtools on page reload. Any insights? Do I need to require the desired ns somewhere in the bb nrepl server task pipeline?

borkdude 2024-12-16T19:38:51.166749Z

You need to be in the right namespace before you can evaluate a var that's defined in that namespace, but you could try to evaluate the fully qualified symbol

chromalchemy 2024-12-16T19:41:09.443249Z

so if my scittle cljs ns is playground , then the fully qualified symbol would be playground/test-trace ?

borkdude 2024-12-16T19:41:58.187759Z

yes

borkdude 2024-12-16T19:42:21.885399Z

if that also fails, try something like inc or whatever is defined in clojure.core

chromalchemy 2024-12-16T19:42:40.174669Z

Ok, will try.

chromalchemy 2024-12-16T19:43:50.063029Z

How can i “be” in the right namespace to use unqualified symbols? Like how it works when I jack in with Calva first? Maybe using :preloads in bp/start! ?

borkdude 2024-12-16T19:44:28.005199Z

add (in-ns 'playground) to your expression?

borkdude 2024-12-16T19:45:15.919809Z

I don't remember what preloads does in bp/start, been a while

borkdude 2024-12-16T19:45:21.681319Z

but sounds relevant

chromalchemy 2024-12-16T19:46:38.427099Z

Hoping to initialize this in the task, so I dont have to add it to every call. Seems like I could add it to :expr (first *command-line-args*)

borkdude 2024-12-16T19:46:52.323519Z

sure, yes

borkdude 2024-12-16T19:47:25.211779Z

also perhaps you can provide :ns in the nrepl client? if not, we could probably add that

borkdude 2024-12-16T19:47:31.304159Z

this would likely solve it as well

borkdude 2024-12-16T19:48:35.328749Z

I think that would be the proper solution tbh

chromalchemy 2024-12-16T19:50:10.383449Z

will try this also:

:expr (do (in-ns 'playground) (first *command-line-args*))

borkdude 2024-12-16T19:50:25.746209Z

yep that's good, expect that the last thing is a string

borkdude 2024-12-16T19:50:36.151799Z

so make the whole thing a string

chromalchemy 2024-12-16T19:52:12.421809Z

Oh right, thanks!

chromalchemy 2024-12-16T19:52:15.623019Z

> provide :ns in the nrepl client you mean babashka/nrepl-client ?

borkdude 2024-12-16T19:52:59.494639Z

yes, but it first needs to support it, currently it doesn't I think

borkdude 2024-12-16T19:54:11.739399Z

issue welcome + PR, you can just try this locally I guess until it works. sending the `"ns" "playground" in the bencode message should make this work

chromalchemy 2024-12-16T19:55:30.628929Z

Ok will try :

:expr (str "(do (in-ns 'playground) " (first *command-line-args*) ")")

borkdude 2024-12-16T19:55:38.969879Z

well actually it doesn't support this in the sci nrepl server either yet

borkdude 2024-12-16T19:55:47.937059Z

both sides should support this, it's a common nrepl option

chromalchemy 2024-12-16T19:58:20.871629Z

Works!! 🙌 Thank you!

chromalchemy 2024-12-16T19:58:32.746239Z

This is for my cljs in Photoshop project I’ve been toying with for a few years. If i can flesh out a meaningful api and reproducible setup I look forward to publishing it sometime.

borkdude 2024-12-16T19:58:53.066569Z

:-D

chromalchemy 2024-12-16T20:00:49.606539Z

I’m using the BB task to send commands to repl from Talon voice (python shelling out). So voice-activated clj functions in Photoshop, while otherwise working manually.

chromalchemy 2024-12-16T20:01:21.579739Z

And no jvm process overhead!

borkdude 2024-12-16T20:02:41.115339Z

:)