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)
nilI 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
and run with clojure -M:whatever/dev instead of a native binary to easy iterating
This is a cool idea :) https://www.reddit.com/r/Clojure/comments/1r71ta4/i_made_a_small_zsh_plugin_that_lets_you_write/
Looks cool! Reminds me a bit of the pipelines with Closh
closh is mentioned in the readme
Ah I missed the hidden text
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
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!
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!)
delicious !!!
Amazing! I don't know what to do with TUIs yet (sure it will come!), but I love the rebl-readline addition
sorry inspiration, feels like it
yes, inspiration
you can now do everything with babashka thats so nice. Small tools big scripts whatever thats so so cool thank you @borkdude
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
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?
https://github.com/babashka/pod-registry/blob/master/examples/go_sqlite3.clj
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)
but no we have to look at the binary size !!!
maybe one day I will be convinced. like with jline... :)
sqlite is a bit more difficult since it's not native to Java
i know 😞
just found this: https://quarkus.io/blog/sqlite4j-pure-java-sqlite/
i used to write a lot java in my career but i have never seen such thing 😄 i was always using derby or hsql
if i needed something small
what the hack it uses the .so to connect thats amazing
> • 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
it uses a webassembly runtime
oh my god
I guess if it compiles to JVM bytecode you don't need the WASM thing afterwards
ah yeah you are right
and with graal the bytecode would be compiled to "native" code
I'm experimenting now ;)
man @borkdude you are incredible
just experimenting, it might take me another three years to adopt it ;)
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
now I'll try to add it to bb and will inspect the binary size
$ 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 dbhrm yeah we are at what now 60
well on my mac it's 70
and with this included it's 80
ok bun has 100mb 😄 \
so thats not to bad i guess
man and we have tools over tools allready
but anyway @borkdude let it sink first cause for me it was just like those stories "hold my beer ..." 😉
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
hmm, no, it should work according to these docs: https://docs.quarkiverse.io/quarkus-jdbc-sqlite4j/dev/index.html
it seems like it works with some kind of backup workaround to persist to disk
so not ready for "production" yet
see good that we talked about it
probably needs another 3 years to mature ;)
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
I'll let this sit here for a while: https://github.com/babashka/babashka/blob/master/doc/adr/sqlite4j.md
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
borkdude and everybody who makes babashka happen: y'all are amazing. It is such a joy
i have forgotten to tell @borkdude the encoding thing works like a chram you saved me a ton of work THANK YOU!!!
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."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"))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?
@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/
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.
@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...
Still looking for specific recommendations for using bb to handle a su - <user> -c "<series of commands>" style command...
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
Yeah, I was wondering whether breaking things into several small scripts might be a good way forward here...
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)
Right, bb tasks are a ways down the road at this point, once I have a bunch more scripts rewritten 🙂
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 itprobably (shell "su" "-c" ...) would work too, without the bash -c
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.> 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)
@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))(I confirmed this produces identical results to the previous shell script)