This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-10-11
Channels
- # announcements (5)
- # babashka (43)
- # beginners (78)
- # calva (1)
- # cider (35)
- # clj-kondo (15)
- # clj-otel (3)
- # cljs-dev (2)
- # clojure (24)
- # clojure-denmark (1)
- # clojure-dev (9)
- # clojure-europe (43)
- # clojure-israel (1)
- # clojure-italy (1)
- # clojure-losangeles (3)
- # clojure-nl (1)
- # clojure-norway (54)
- # clojure-romania (1)
- # clojure-uk (2)
- # clojurescript (1)
- # core-async (25)
- # cursive (7)
- # datascript (6)
- # datomic (7)
- # docker (2)
- # emacs (2)
- # events (8)
- # exercism (2)
- # fulcro (2)
- # hyperfiddle (16)
- # lsp (46)
- # malli (10)
- # membrane (2)
- # music (6)
- # nbb (30)
- # off-topic (49)
- # polylith (4)
- # reagent (3)
- # releases (4)
- # shadow-cljs (5)
- # slack-help (1)
- # sql (2)
- # testing (2)
- # timbre (6)
- # tools-deps (29)
- # xtdb (36)
Anyone wants to try the new self-contained binary uberjar approach? https://github.com/babashka/babashka/wiki/Self-contained-executable#uberjar


Having invested in using the bb tasks approach, is there any way that that could be wrapped into an uberjar?
@U4C3ZU6KX tasks are project-specific, at least that is the intention
Interesting - I see them as alternative entry points into my code. The :init acts as the first part of a main and the task then is as if the main calls a particular end point.
@U4C3ZU6KX I'd probably use babashka.cli subcommands for your use case: https://github.com/babashka/cli#subcommands
@U4C3ZU6KX I found a way to run bb tasks in a self-contained binary. Use this as your main entry point:
(ns buber
(:require [babashka.tasks :as tasks]))
(defn -main [task & args]
(binding [*command-line-args* args]
(tasks/run (symbol task))))

....I just tested it on windows and yes, it works as expected ๐
copy /b bb.exe + foo.jar mybb.exe
C:\foo>mybb.exe 1 2 3
("1" "2" "3") 6
what a time to be alive!
(โข๏ธ) ๐
So if you're building some babashka CLI app, I believe you'll be able to generate native binaries for all the combinations of OSs (mac, linux, windows) and platforms (arm, amd64) in matter of seconds. No compilation whatsover. Looking forward to see how fast such CI pipeline can run ๐ค.
(better late than never...)
So I'm looking at this now, for our usecase we have a seperate bb.edn
with all the tasks defined in it; is it going to be preferable to refactor it to be a babashka.cli program instead?
> and then put your bb.edn
in META-INF
in the uberjar
I'm new to java packaging, so while I understand what this means I'm lost on how to do it ๐
I've been debating refactoring it to babashka.cli anyway, since we'd benefit from the extra additions, so having to do so to make this simpler is no trouble ๐
@U043RSZ25HQ So how to deal with tasks:
โข Add bb.edn
to META-INF/bb.edn
E.g.:
{:paths ["resources"]}
mkdir -p resources/META-INF
cp bb.edn resources/META-INF
In src/buber.clj
:
(ns buber
(:require [babashka.tasks :as tasks]))
(defn -main [task & args]
(binding [*command-line-args* args]
(tasks/run (symbol task))))
and then
bb uberjar tasks.jar -m buber
I added docs about tasks in self-contained binaries here now: https://github.com/babashka/babashka/wiki/Self-contained-executable#tasks
Iโve been working with this approach today. I can even quickly create standalone binaries on github actions for all platforms on a single builder instance. Very nice. The only issue Iโm running into now is that MacOS binaries need to be signed/notarized or they will give the usual annoying warning / message.
@U09N5N31T the bb binary itself isn't notarized. you won't have any problems with this if you download the binaries via a terminal. just don't download them via a browser and unzip them via finder
@U09N5N31T I've seen something similar on windows & avast antivirus. Once avast saw a new binary, it insisted on having it analysed on first execution. I have to wait a couple of 10s of seconds, but once it finished, it was working normally.
Btw how many different binaries did you build and how quick that process was? seconds?
it is only when you go through Finder's unzip, that macOS will think "wtf, a binary, let's set some attributes so nobody can run this" you undo that using:
sudo xattr -c ./my-binary
Ooh good to know this is hooked into the browser download.
hi I am interested in using https://github.com/borkdude/etaoin-graal. Is this maintained and usable with Babashka or should I consider an alternative?
Nice! Thank you :face_with_cowboy_hat:
I am spawning a babashka process to incrementally build a background task manager. This will likely get native compiled in the end. I noticed it terminates after receiving a SIGINT
and there doesn't seem to be a way to handle it in babashka?
By "handle it" do you mean ignore it or react to it? You can add a shutdown hook with babashka:
(.addShutdownHook (Runtime/getRuntime) (Thread. (fn [] ...)))
Otherwise you'd have to try using jdk.internal.misc.Signal
to implement a signal handler.Thanks! This solved it. I guess I just had not properly done this before and didnโt know how to capture it
Hey I just started a REPL and when def'ing vars I'm seeing this output #<Var@5f51c5c6: #{1 4 2}>
instead of the typical namespace/var name combo. Is this expected behavior for bb? I would guess not.
I just attempted to repro... I feel like there was maybe a time when bb did this - are you running the latest version, and do you have a specific repro? Using bb repl
and doing (def x #{ 1 2 3})
I get #'user/x
- could maybe be a namespace thing?
ah yeah it seems I'm on a rather old version at home 1.0.168
and explains why I see this here and not at work where I have a release from just a few months ago