babashka

primer 2026-02-17T03:50:07.553139Z

I'm writing a pod, and most of the scenarios are working well. But I'm running into an issue in one case where Babashka is throwing an exception when preparing to invoke my pod. Note: I'm running Babashka v1.12.213 under windows. My pod "format" is "json". The problem occurs when I try to invoke a function implemented by my pod when passing a map. The following line works (it's actually nonsense for my real use case, but my pod is invoked and detects a parse error which is successfully sent back and thrown on the babashka side.) (my-pod-func {:a 1} "foo" "bar") The following line throws an exception before my pod sees anything: (my-pod-func "foo" "bar" {:a 1}) Below is a stack trace from the repl.

user=> (pst *e)
ExceptionInfo Unsupported source value type: JObject {}
        babashka.pods.impl/processor (impl.clj:238)
        babashka.pods.sci/load-pod/fn--30599 (sci.clj:122)
        sci.impl.vars/binding-conveyor-fn/fn--411 (vars.cljc:129)
        clojure.core/binding-conveyor-fn/fn--5844 (core.clj:2047)
        java.util.concurrent.FutureTask.run (FutureTask.java:328)
        java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1090)
        java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:614)
        java.lang.Thread.runWith (Thread.java:1487)
        java.lang.Thread.run (Thread.java:1474)
        com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine (PlatformThreads.java:832)
        com.oracle.svm.core.thread.PlatformThreads.threadStartRoutine (PlatformThreads.java:808)
nil

borkdude 2026-02-17T09:30:08.484059Z

I don't know, doesn't ring a bell. Perhaps you can try to debug with a local checkout of babashka.pods and put some debugging info in there

borkdude 2026-02-17T09:30:22.288259Z

and run with clojure -M:whatever/dev instead of a native binary to easy iterating

borkdude 2026-02-17T11:00:08.302149Z

This is a cool idea :) https://www.reddit.com/r/Clojure/comments/1r71ta4/i_made_a_small_zsh_plugin_that_lets_you_write/

🤩 3
2026-02-17T11:28:39.520299Z

Looks cool! Reminds me a bit of the pipelines with Closh

borkdude 2026-02-17T11:29:02.882809Z

closh is mentioned in the readme

2026-02-17T11:29:35.286059Z

Ah I missed the hidden text

borkdude 2026-02-17T11:30:38.920579Z

I think with jline now included (just released) we could make a shell that works on any OS in the same way solely using babashka

2026-02-17T11:32:44.542499Z

Yeah that is really cool. At the time when Closh came up, babashka wasn't a thing yet and I was hoping Closh would enable clojure for bash scripts. Happy Babashka made it this far!

borkdude 2026-02-17T11:23:28.336059Z

Babashka 1.12.215: Revenge of the TUIs https://blog.michielborkent.nl/babashka-1.12.215.html One of the most exciting babashka releases thus far! (If you encounter the blog post link on HN, please upvote it but please don't share a direct HN link as this is penalized by HN's algorithm. Thank you!)

8
🔥 8
❤️ 9
🎉 10
m3tti 2026-02-17T11:32:55.133479Z

delicious !!!

2026-02-17T11:36:11.805769Z

Amazing! I don't know what to do with TUIs yet (sure it will come!), but I love the rebl-readline addition

2026-02-17T11:36:42.578559Z

sorry inspiration, feels like it

borkdude 2026-02-17T11:36:49.333139Z

yes, inspiration

m3tti 2026-02-17T11:37:48.887849Z

you can now do everything with babashka thats so nice. Small tools big scripts whatever thats so so cool thank you @borkdude

m3tti 2026-02-17T11:38:32.401429Z

babashka is really full featured only thing i miss is sqlite 😉 that would be awesome to have in the base but maybe its just one of my itches i have

borkdude 2026-02-17T11:39:02.973729Z

it would certainly be nice to have a database on board, but as a second best option we have pod-babashka-sqlite, have you tried it?

❤️ 1
m3tti 2026-02-17T11:44:10.521559Z

i know and its cool but i'm looking at bun and i liked the idea to have it directly in the binary. And no i don't want to have full jdbc 😄 (but than maybe that would also be nice to have a swiss army knive to look into your databases)

m3tti 2026-02-17T11:44:37.817359Z

but no we have to look at the binary size !!!

borkdude 2026-02-17T11:47:25.078509Z

maybe one day I will be convinced. like with jline... :)

borkdude 2026-02-17T11:47:44.656539Z

sqlite is a bit more difficult since it's not native to Java

m3tti 2026-02-17T11:47:54.448509Z

i know 😞

borkdude 2026-02-17T11:48:23.498619Z

just found this: https://quarkus.io/blog/sqlite4j-pure-java-sqlite/

👀 1
😮 1
m3tti 2026-02-17T11:49:09.759299Z

i used to write a lot java in my career but i have never seen such thing 😄 i was always using derby or hsql

m3tti 2026-02-17T11:49:17.495739Z

if i needed something small

m3tti 2026-02-17T11:49:55.416979Z

what the hack it uses the .so to connect thats amazing

borkdude 2026-02-17T11:50:56.325839Z

> • quarkus-jdbc-sqlite4j builds on top of the fork https://github.com/roastedroot/sqlite4j which instead compiles SQLite to pure Java bytecode thanks to https://github.com/dylibso/chicory and directly interacts with it

🤯 1
borkdude 2026-02-17T11:51:24.978279Z

it uses a webassembly runtime

m3tti 2026-02-17T11:51:33.521719Z

oh my god

borkdude 2026-02-17T11:52:59.665659Z

I guess if it compiles to JVM bytecode you don't need the WASM thing afterwards

m3tti 2026-02-17T12:03:45.122779Z

ah yeah you are right

m3tti 2026-02-17T12:04:01.055719Z

and with graal the bytecode would be compiled to "native" code

borkdude 2026-02-17T12:04:58.240929Z

I'm experimenting now ;)

m3tti 2026-02-17T12:08:28.911189Z

man @borkdude you are incredible

borkdude 2026-02-17T12:09:26.264839Z

just experimenting, it might take me another three years to adopt it ;)

m3tti 2026-02-17T12:11:07.098789Z

no stress its just ideas @borkdude babashka is allready incredible what it does i love it and the workflow and all the stuff around it

borkdude 2026-02-17T12:13:19.824889Z

(https://github.com/borkdude/sqlite4j-clojure-native-image)

borkdude 2026-02-17T12:17:27.201139Z

now I'll try to add it to bb and will inspect the binary size

borkdude 2026-02-17T12:32:51.203099Z

$ bb /Users/borkdude/dev/babashka/test-sqlite4j.bb
All persons:
  1: Alice (age 30)
  2: Bob (age 25)
  3: Charlie (age 35)

Persons over 28:
  Alice (age 30)
  Charlie (age 35)
"only" a 10mb increase. not bad I guess for adding a sql db

m3tti 2026-02-17T12:34:21.573529Z

hrm yeah we are at what now 60

borkdude 2026-02-17T12:34:34.218759Z

well on my mac it's 70

borkdude 2026-02-17T12:34:38.751899Z

and with this included it's 80

m3tti 2026-02-17T12:35:19.776649Z

ok bun has 100mb 😄 \

m3tti 2026-02-17T12:35:33.181499Z

so thats not to bad i guess

m3tti 2026-02-17T12:35:44.406789Z

man and we have tools over tools allready

m3tti 2026-02-17T12:36:30.199399Z

but anyway @borkdude let it sink first cause for me it was just like those stories "hold my beer ..." 😉

borkdude 2026-02-17T12:37:32.731339Z

hehe indeed. I think one thing I'm hitting here is that persisting to a .db file doesn't work due to the "zerofs" thing

borkdude 2026-02-17T12:39:03.355309Z

hmm, no, it should work according to these docs: https://docs.quarkiverse.io/quarkus-jdbc-sqlite4j/dev/index.html

borkdude 2026-02-17T12:49:05.571299Z

it seems like it works with some kind of backup workaround to persist to disk

borkdude 2026-02-17T12:49:10.028529Z

so not ready for "production" yet

m3tti 2026-02-17T12:49:35.466609Z

see good that we talked about it

borkdude 2026-02-17T12:50:47.457549Z

probably needs another 3 years to mature ;)

borkdude 2026-02-17T12:51:20.860669Z

The FFM support landed in Java 22 but it was only released for GraalVM in 2025 september, and I needed this for JLine so my timing was pretty good that I really tried integrating it now in 2026

borkdude 2026-02-17T12:55:00.297549Z

I'll let this sit here for a while: https://github.com/babashka/babashka/blob/master/doc/adr/sqlite4j.md

Johnny Hane 2026-02-17T23:47:14.522409Z

I was mostly excited about the TUI possibilities with this release, but the console REPL upgrades are wicked cool. I was underestimating the usability improvement. Especially for showing off babashka and running quick demos

Johnny Hane 2026-02-17T23:48:31.621639Z

borkdude and everybody who makes babashka happen: y'all are amazing. It is such a joy

💯 2
❤️ 2
m3tti 2026-02-20T08:09:13.726979Z

i have forgotten to tell @borkdude the encoding thing works like a chram you saved me a ton of work THANK YOU!!!

🎉 1
seancorfield 2026-02-17T17:29:25.384249Z

I'm looking at more of our bash scripts and contemplating converting them to Babashka. One script has a lot of lines like the following (it runs as root) and I was wondering how best to handle this in bb?

su - tomcat -c "cd ${base} && unzip -qo ${staging}/${stamp} && chmod -R +x build/bin build/clojure/bin && echo Done."

seancorfield 2026-02-17T17:31:21.594739Z

I've already converted some bash scripts, but I ended up with this for a bunch of piped processes which I don't exactly love, compared to the original bash code:

(p/pipeline
 (p/pb "cat" raw) (p/pb "sed" "s;[^[]*\\[;;") (p/pb "sed" "s;\\] -.*;;")
 (p/pb "sort") (p/pb "uniq" "-c")
 (p/pb {:out :write :out-file (io/file summary)} "sort" "-n"))

seancorfield 2026-02-17T17:32:39.135729Z

So, I'm sort of wondering whether there are some scripts that maybe are better left as bash, if they're stringing together a lot of commands rather than being mostly logic and/or data manipulation?

amiorin 2026-02-17T20:45:59.789219Z

@seancorfield Sticking with Bash scripts is fine, but I would render them with Selmer instead of using error-prone syntax like ${base}, and use as few features of the Bash language as possible. I have forked your deps-new (amazing idea) and extended it with Selmer: https://bigconfig.it/api/render/

Bob B 2026-02-17T21:03:42.906809Z

I'm curious on the pipeline thing... maybe this is just an intermediate step, but I think the end game is maybe more writing the pipeline in clojure, e.g. slurp the file, thread it through str/replace or str/escape, etc.

seancorfield 2026-02-17T21:42:19.406269Z

@highpressurecarsalesm True, the cat, sed, sed, sort part could all easily be written directly in Clojure. uniq -c and sort -n are less trivial -- and Linux already has those commands so...

seancorfield 2026-02-17T21:43:53.717249Z

Still looking for specific recommendations for using bb to handle a su - <user> -c "<series of commands>" style command...

Bob B 2026-02-17T21:46:19.592549Z

just spitballing here - how about putting the <series of commands> into a task/script, and then using the su part as-is, so it's a bit like if <series of commands> were put into a shell script

seancorfield 2026-02-17T21:53:40.431929Z

Yeah, I was wondering whether breaking things into several small scripts might be a good way forward here...

Bob B 2026-02-17T21:58:07.321019Z

I don't want to suggest huge sweeping changes, but I could potentially see a set of tasks in there that could have dependencies so that something like bb deploy could invoke a series of tasks in order (or in parallel if that makes sense)

seancorfield 2026-02-17T22:02:55.824359Z

Right, bb tasks are a ways down the road at this point, once I have a bunch more scripts rewritten 🙂

borkdude 2026-02-17T22:08:34.431529Z

su - tomcat -c "cd ${base} && unzip -qo ${staging}/${stamp} && chmod -R +x build/bin build/clojure/bin && echo Done."
you could just copy paste that into (shell "bash" "-c" ...) and be done. or as Bob suggests, write into smaller scripts There is no way to change the user in a JVM program and that also goes for bb. So if you are using su -c anyway, you might as well keep it

borkdude 2026-02-17T22:09:02.524639Z

probably (shell "su" "-c" ...) would work too, without the bash -c

seancorfield 2026-02-17T22:20:24.587509Z

user=> (require '[babashka.process :as p])
nil
user=> (p/shell "su" "-" "tomcat" "-c" "pwd")
/opt/tomcat
{:proc #object[java.lang.ProcessImpl 0x6a577938 "Process[pid=117587, exitValue=0]"] ...
So, yeah, that works.

Bob B 2026-02-17T23:49:56.735819Z

> uniq -c and sort -n are less trivial not to drag this out too much, but I don't think these end up being too bad - admittedly, there might be details for which I'm just missing some context or whatever, but I think uniq -c is basically frequencies(after a split-lines), and since the frequencies are then in a map, sort -n is roughly sort-by val (or more precisely (juxt val key) if the text sorting matters in addition to the count)

seancorfield 2026-02-18T00:32:45.723979Z

@highpressurecarsalesm That pipeline in pure Clojure:

(->> (slurp raw)
     (str/split-lines)
     (into []
           (comp (map #(str/replace % #"^[^]]*\[" ""))
                 (map #(str/replace % #"\] -.*" ""))))
     (frequencies)
     (sort-by (juxt val key))
     (map #(format "%7d %s\n" (val %) (key %)))
     (str/join)
     (spit summary))

seancorfield 2026-02-18T00:33:58.107059Z

(I confirmed this produces identical results to the previous shell script)