Fork me on GitHub
Mikko Harju07:06:10

Hi! I'm trying to compile the babashka on OS X from sources, and I'm getting this

maharj:babashka git:(master) $ script/uberjar
openjdk version "1.8.0_252"
OpenJDK Runtime Environment (build 1.8.0_252-b09)
OpenJDK 64-Bit Server VM GraalVM CE 20.1.0 (build 25.252-b09-jvmci-20.1-b02, mixed mode)
Compiling babashka.curl
Compiling babashka.impl.async
Compiling babashka.impl.bencode
Syntax error macroexpanding at (interop.cljc:1:1).
Execution error (UnsupportedClassVersionError) at java.lang.ClassLoader/defineClass1 (
sci/impl/Reflector has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
It seems that something is picking up a different compiler at some stage, but I'm quite baffled what and who? Has someone seen this before?

Mikko Harju07:06:36

This is such an awesome tool – I want to do some JDBC-related stuff so hence the need to do a custom build. Been using the brew-version for quite a while now to do things. Thanks so much for making this 🙂


I thought I could be clever and resolve static Java fields at analysis time instead of "interpretation" time. But now I realize, these fields could be mutable 😕


@helios @dominicm

$ export BABASHKA_CLASSPATH=$(clojure -Spath -Sdeps '{:deps {aero {:mvn/version "1.1.6"}}}')
$ rlwrap lein bb
user=> (require '[aero.core :refer (read-config)])
user=> (slurp "/tmp/config.edn")
"{:classpath #env \"BABASHKA_CLASSPATH\"}\n"
user=> (-> (read-config "/tmp/config.edn") :classpath (subs 0 50))

parrot 2

This is with commit cc4ac98795c1134efc48dc1b381124e4937fd7c7. New binary should arrive soon in #babashka_circleci_builds for testing.


$ time bb -e "(require '[aero.core :refer [read-config]]) (-> (read-config \"/tmp/config.edn\") :classpath (subs 0 100))"
bb -e    0.03s  user 0.02s system 93% cpu 0.060 total


There are probably still cases that don't work, so I'd appreciate some testing


Does anyone know how to create a self-running bb script on Windows 10?


do you mean with a shebang?


Yes. The problem is I don’t have WSL on my work laptop.


don't know, but if you find it out, it would be nice to document


@dominicm Small update: I've got a metadata issue with bb + aero in alpha.core/reassemble...


@borkdude what's the problem? :)


Oh, you probably don't allow dynamic evaluation like that right?


This works:

$ clj -A:bb-local -cp src -e "(require '[aero.core :as a]) (a/read-config ( \"{:x 1 :y #or [#ref [:x] \\\"bar\\\"]}\"))"
{:x 1, :y 1}
but this doesn't:
$ clj -A:bb-local -cp src -e "(require '[aero.core :as a]) (a/read-config ( \"{:y #or [#ref [:x] \\\"bar\\\"]}\"))"
WARNING: Unable to resolve "#ref [:x]" at [:y :form 0]
java.lang.Exception: Cannot call nil as a function. [at line 16, column 3]


so a dangling ref


Oh, well boo you slack


Upload as file is better for large code chunks


I’ve found a counter example of where Sci’s :termination-safe true doesn’t (really) protect you. It’s using recursion:

((fn a [n] (if (#{0 1} n) 1 (+ (a (- n 2)) (a (- n 1))))) 20)
With n = 100 I had to kill my jvm. Is this within the scope of Sci?


Or with bb:

time bb -e '((fn a [n] (if (#{0 1} n) 1 (+ (a (- n 2)) (a (- n 1)))))  30)'
bb -e '((fn a [n] (if (#{0 1} n) 1 (+ (a (- n 2)) (a (- n 1)))))  30)'  6.82s user 0.11s system 99% cpu 6.944 total


40 doesn’t finish with 5 minutes:

time bb -e '((fn a [n] (if (#{0 1} n) 1 (+ (a (- n 2)) (a (- n 1)))))  40)'
^Cbb -e '((fn a [n] (if (#{0 1} n) 1 (+ (a (- n 2)) (a (- n 1)))))  40)'  287.09s user 1.22s system 99% cpu 4:49.90 total


I’m guessing protection against situations like this would require a counting mechanism at the interpreter level Not sure what other consequences this would have


@dominicm yes!

$ clj -A:bb-local -cp src -e "(require '[aero.core :as a]) (a/read-config ( \"{:y #or [#ref [:x] \\\"bar\\\"]}\"))"
WARNING: Unable to resolve "#ref [:x]" at [:y :form 0]
{:y "bar"}


Woohoo, all aero tests are now passing in bb except for one minor thing which I know how to fix.

metal 1

This is really exciting… I'm wondering what crazy things I can do with this. One idea is a CLI migration tool that will read my config.edn without paying a startup penalty!


Or maybe static analysis of my config file for linting purposes… so many ideas!


@dominicm for static analysis, you might also want to look at:


babashka v0.1.1: This release can now run clj-commons/camel-snake-kebab and juxt/aero as libraries.