Fork me on GitHub
Luis Santos19:02:40

Hi everyone, I'm currently trying to use records in babashka but they don't seem to work. The documentation says that the implementation is different from clojure but that it should work as expected. In the example bellow the messages are never printed. Am I doing something wrong? Should I open a bug or is this a know limitation? Thanks

(defprotocol Task
  (test [this])
  (test2 [this]))

(defrecord TaskImpl [a b]
  (test  [this] (println "It should be printed"))

(defmethod test2 TaskImpl []
  (println "It should be printed")

(let [ t (->TaskImpl "a" "b") ]
  (.test t)
  (.test2 t))


@luis559 Made it a little bit linter proof ;). Note that you can just call the methods by name, you don't have to use .test, although we could probably make that work

(ns foo (:refer-clojure :exclude [test]))

(defprotocol Task
  (test [this])
  (test2 [this]))

(defrecord TaskImpl [a b]
  (test [_] (println "It should be printed (proto)")))

(defmethod test2 TaskImpl [_]
  (println "It should be printed (mm)"))

(let [ t (->TaskImpl "a" "b") ]
  (test t)
  (test2 t))
It should be printed (proto)
It should be printed (mm)

Luis Santos19:02:13

Thanks. Let me try it again.

Luis Santos20:02:30

@borkdude Thanks. I managed to get it to work. I figured out what my problem was. I was not able to call methods my name like you suggested because I forgot to import them. I guess the biggest difference between the 2 approaches would be weather or not you one needs to import the methods. To make sure my library is compatible with clojure and babashka I have to make sure I don't use the dot syntax.



binary: "/usr/bin/ffprobe"
args:   [:show_format :show_streams ""]
task:   {:ss nil, :ex #error {
 :cause "error=2, No such file or directory"
It's probably best to look on the path for ffprobe?

Luis Santos20:02:39

I will update the docs. But if you remove the binary name it will use whatever is available in the path.


Ah I didn't know that, thanks.


Apologies if I missed something obvious in the docs - how can I have a script I am writing return a non-zero exit code? I'm giving babashka a whirl for the first time today, writing a little helper script so I can have one command to properly pick the right command for unpacking a given file. I've googled "tar gz command line options" more than I care to admit, and then today downloaded something that was .tar.xz. Figured it was time to scratch the itch. I've called it bunpack 🐰 🫓


doh. Never fails, ask a question publicly, find your answer immediately thereafter. I believe System/exit is what I needed


@robertfrederickwarner That's it and don't worry, feel free to ask anything here


Thanks @borkdude. Your prolific work astounds! I always loathed writing bash scripts, this is a wonderful addition to the ecosystem


This looks exciting, thanks for making it babashka compatible @luis559 :)

🆒 3
Luis Santos20:02:29

Thank for helping and sorry misspelling babashka. ;)

Eccentric J21:02:50

Used Babashka over cgi to create a really basic line art svg generator;fg=ffffff

🆒 2
Eccentric J21:02:39 src if anyone’s interested in how it works

Eccentric J21:02:51

It did bring about some rough edges I’m trying to come up with better solutions for. The first one is the shebang for the entry point script. #!/home1/<username>/bin/bb makes it less portable. If I could set the PATH variable then I could use #!/user/bin/end bb but unfortunately cgi is pretty locked down so most environment variables are stripped away if set with Apache (according to my research and tests). I’m wondering if I could write a script that behaves like env that will set the path, point to bb, and perhaps supply the src dir relative to the entrypoint script.


@U8WFYMFRU Maybe you can str/replace the shebang once you deploy the script to bluehost?


Is it possible to set the interpreter in the cgi config (for a certain file extension)? (sorry, no idea, I haven't used this myself)

Eccentric J22:02:13

As far as I found I can only modify a .htaccess to specify:

AddHandler cgi-script .clj
So that apache knows what to do with requests for that file.

Eccentric J22:02:46

There’s also some runtime config that would be nice to automate so I think a wrapper script would be a reasonable approach


Yeah, so maybe making a before-deploy hook which rewrites your script just in time, will work


yeah, you could write a little bash wrapper

Eccentric J22:02:43

Deploys are pretty primitive right now, sometimes SFTP, sometimes rsync, sometimes scp

Eccentric J22:02:56

Is there a way to load code from a local file not on the classpath? Maybe load-file?


Yep, that's the one

Eccentric J23:02:32


export PATH="/home1/<username>/bin/:$PATH"
export CLJ_BB_LIB_PATH="/home1/<username>/lib/"

exec env bb -cp src "[email protected]"
Making that my bbenv wrapper which I could reference from the parent dir or create a sibling symlink to. Should do the trick to keep host specific things out of the repos.


@U8WFYMFRU this is cool! If you plan to expand on the idea with more SVG elements, my library might be interesting to you. I'm working hard to get it polished, but some of the functionality might be useful to you as is.

Eccentric J20:03:35

That’s really cool! I foresee making more generative art experiments in the future. Thanks!

❤️ 1
Eccentric J21:02:39

Then at least it would be like #!../../bin/devenv bb which is a bit easier to replicate in a local docker for development or move to another server.


Any suggested exemplars for a published babashka script intended for use on the command line? I pushed my little bunpack script up onto github, if anyone has use for it or any suggestions for how to package it in a nicely reusable form.

🎉 2

You could use a shebang so you don't need the bash wrapper:

#!/usr/bin/env bb


And then just place the .clj script on the path


I started with that but my emacs setup was throwing a hissy fit when trying to auto format the buffer


@robertfrederickwarner If you are in clojure mode it should deal well with the shebang


I may be making some basic mistake in how I'm interacting with the code. Currently, I'm running cider-jack-in-clj to connect my repl, and then cider-format-buffer . That results in an Invalid symbol: !/usr/bin/env. error


Have you put the hash sign in front of this?


Ah. I wonder if this is just starting up a regular clojure REPL. I'm guessing I'd want this to fire up a babashka repl instead?


Then that could be a bug in cider-format-buffer. I'm always just using this function:

(defun iwb ()
  "Indent whole buffer."
  (indent-region (point-min) (point-max) nil)
  (untabify (point-min) (point-max)))
Might be worth filing this bug to CIDER


Yeah, that will start a regular clojure JVM


I've got to go now, later 💤


Thanks for the tips! Good night


I meant to be learning CLJS today. I started installing shadow-js and got to the "install node" step, had to google "extract tar.xz" file.. and now here we are. I haven't learned CLJS but at least I got my feet wet with bb 😋

babashka 2
replied to a thread:

did more playing here, these are some others protocols that are missing:

There may be more, according to Potemkin docs (, these are the nescessary protocols on the JVM: clojure.lang.IPersistentCollection, clojure.lang.IPersistentMap, clojure.lang.Counted, clojure.lang.Seqable, clojure.lang.ILookup, clojure.lang.Associative, clojure.lang.IObj, java.lang.Object, java.util.Map, java.util.concurrent.Callable, java.lang.Runnable, and clojure.lang.IFn, but I'm not sure if we need all of them to get a workable map for Babashka purposes