Fork me on GitHub

An example on talking to a babashka-pod with common-lisp. Just tried it out for chills

🤓 2

@dorabThanks for sponsoring on Github. Would you like an invite to the private sponsors channel?


Sure. Thanks.

Eamonn Sullivan10:02:41

How do you sponsor on Github? I've never done that, though I probably should...


Thanks for your kind donation on Kofi!

Eamonn Sullivan08:02:57

Well, it's not much, but there's so many different packages that I use every day. I made several one-off $/£/€ donations this morning and set a reminder to do the same next year. I'll make it a Lent thing!

Eamonn Sullivan10:02:34

Oh, I see the opencollective link now...


@eamonn.sullivan You can go to and then it should be self-explanatory I hope


Thanks for considering

👍 2

As a sponsor you will get priority in bug reports and also access to the private sponsors channel, but the main thing is to ensure continuity of this project.


@pfeodrippe Thanks for sponsoring! Would you like to have access to the private sponsors channel?


Hi @U04V15CAJ o/ Yes, of course :) Thanks

Mikko Harju14:02:22

What's the best way to achieve . ${MY_CNF_SCRIPT} in babashka? Basically that file includes just a bunch of bash variables that can be then subsequently used later in the script. I'd like to reuse that file and just get the vars to babashka env

Mikko Harju14:02:02

I have a legacy project that has extensive bash tooling and I'm extending that setup with a couple of separate scripts that use babashka instead of Bash


source is a builtin, it’s special that it ‘survives’ the ‘subprocess’, Have you tried making a script that itself does source, and then source that bb script?


actually, I think just setting the env in your babashka and then sourcing that script might work

Mikko Harju14:02:41

Yeah, that is what I imagined what I'll have to do – I thought there could be some nifty way to get the variables set by the script to be incorporated directly withing a babashka script. Thanks!


I don’t think so: The invoker must explicitly be setup to ‘adopt’ the changed env vars, and that’s what source does. Let me know if a simple source where bla does setenv works, I am curious (and at work and cannot check)


I do have a nifty hack here: produce some bash with babashka and source that ;)


Ah, sneaky. You just output a script 🙂 Probably nicer to use process substitution? e.g.

source <(bb -o ...

Mikko Harju18:02:39

Nice, thanks!


Adam is working on some babashka scripts here, while streaming:

🚀 3
🙂 1

Oh nice, I actually asked him to do something like that


Is Adam from the stream in this channel?


I have a solution for his spec problem ;)


I don’t know, but I told him that I found his stream via your post so he’s at least aware of this slack


Never trust a man with two first names


Hey, I resemble that remark 😉


Ah right. So what you can do:

/tmp $ export BABASHKA_CLASSPATH=$(clojure -Spath -Sdeps '{:deps {borkdude/spartan.spec {:git/url "" :sha "e5c9f40ebcc64b27b3e3e83ad2a285ccc0997097"}}}')
/tmp $ cat spartan.clj
(require '[spartan.spec])

(alias 's 'clojure.spec.alpha)

(s/valid? int? 1)

/tmp $ bb -f spartan.clj --uberscript spartan.uber.clj
/tmp $ bb spartan.uber.clj
Using alias will avoid uberscript loading in the source from the "real" spec. And since spartan.spec create the clojure.spec.alpha namespace already, this is a good solution. I will change the spartan.spec README as well.


Thanks for this example. I am able to get your code working, however, it doesn't work when I also pull in my svg library. As soon as I require svg-clj (where the real use of spec occurs), uberscript will pull in clojure spec's code.


If I modify my ns

(ns svg-clj.main
  (:require [clojure.string :as st]
            #_[clojure.spec.alpha :as s] ;; eliminate spec requirement here
            [clojure.pprint :as pp]
            [ :as xml]
               [hiccup.core :refer [html]])
               [cljs.reader :refer [read-string]])))
Then your approach works. I was thinking of spartan as a complete 'drop in' replacement, but I may have to use a reader conditional in my library to get it to work with an uberscript


Yeah, it's a partial drop-in since not everything in spec is implemented (generators and instrumentation). But the way it creates the clojure.spec.alpha namespace is non-standard which confuses the uberscript


If you are using uberscripts solely for the purpose of being able to run them from anywhere, an alternative might be to just add the script "project" directory to the path


These are good suggestions. The uberscript approach was the first one I tried and succeeded with. I still plan to try uberjars as well. It's the next on the list. I'm still very much in the 'exploratory' phase of scripting :)


I love it :)


Another alternative is to create "uberjars" from them and wrap it in a tiny bash wrapper if you don't want to type bb foo.jar

👍 1