Fork me on GitHub
Daniel Jomphe11:04:22

Have you seen the new GitHub Action v5 with bb support? I'm happy, it becomes easy to use most clojure tools.

ā¤ļø 1

@danieljomphe Hadn't seen that, thanks for sharing :)

šŸ™‚ 1
Daniel Jomphe11:04:42

In some GitHub actions, though, I install instead of those tools (see thread for how I do it). I then don't need to install Java to power Clojure.

Daniel Jomphe11:04:59

- name: Install deps.clj, posing as clojure
        run: | 
          # bash script below
Bash script to be run:
latest_release="$(curl -sL )"

echo -e "Downloading $download_url."

curl -o "deps.clj-$" -sL ""

unzip -qqo "deps.clj-$"

rm "deps.clj-$"

sudo mv deps /usr/local/bin/clojure # let it pose as the real Clojure CLI, since later steps will call `clojure` directly!


If you're also installing babashka in the same build, then you can skip this and use bb clojure instead


but then you need to install a bash shim for clojure -> bb clojure . I've posted that once in this channel

Daniel Jomphe11:04:11

Thanks for the tip - yes, but no, it's because the Datomic Cloud Ion deployment tool calls directly clojure <args>. šŸ™‚ So I'm quite happy with deps.clj in this action which only needs "clojure" for this single thing.

šŸ‘ 1
Daniel Jomphe11:04:41

Oh, the bash shim would do it, yes! Then I suppose I could compare binary size of deps vs bb but someone might challenge me in asking: does it truly matter, does it make your action setup even 1 second longer? šŸ™‚


the binary size of deps is way smaller

Daniel Jomphe11:04:51

Yeah, I'd expect deps to be e.g. 20 MB and bb e.g. 80 MB šŸ™‚


seems right

Cora (she/her)15:04:00

this is very much in the maybe-throw-away-but-interesting idea category but I noticed ruby had gotten a file-backed key-value store as part of its stdlib

Cora (she/her)15:04:42

and that seems incredibly useful for a scripting language to have. I've definitely done this myself in a number of different languages in the past


@corasaurus-hex I think there's lots of stuff in the #nbb world for this: there is keyv with multiple adapters. - but we could also easily make a pod around something like this probably from the golang side.

Cora (she/her)17:04:43

I was thinking of it in the context of something built-in that was super simple (like just reads/writes edn to a file) but that would have to exist first before it could even be considered for inclusion

Cora (she/her)17:04:36

it might even be a fun little project


Dumb issue, trying a task using shell but it's failing: bb.edn

{:min-bb-version "0.4.0"
 :tasks {test (shell "cd server && clojure -M:test")}}
bb test
----- Error --------------------------------------------------------------------
Message:  Cannot run program "cd": error=2, No such file or directory 


is cd supported?

Daniel Jomphe21:04:53

Hi Eric, try

{:min-bb-version "0.4.0"
 :tasks {test (shell "cd" "server")}}
splitting cd and server apart first I never can remember how args are expected by shell Once that works, find a way to add back in && clojure ... :)

Daniel Jomphe21:04:15

also, sometimes space characters are required - something is tricky


makes sense! but I think I'll use @U04V15CAJā€™s suggestion

(shell {:dir "server"} "clojure -M:test")

Daniel Jomphe21:04:19

oh yes, that's good, but you'll probably need to split clojure from its args too šŸ™‚ I often use this wrapper:

(defn eshell [& args]
            (let [s-args (str/join " " (map str/trimr args))]
              (println s-args)
              (apply shell args)))

Daniel Jomphe21:04:04

Incredible to be helping you a bit, you who helps us so much!!! :star-struck:


> oh yes, that's good, but you'll probably need to split clojure from its args too Actually I didn't need to split, it worked :thinking_face: Nice wrapper, I think I'll swap to it! > Incredible to be helping you a bit, you who helps us so much!!! šŸ˜„ Thank you!

šŸ™‚ 1

shell does not need splitting


the issue was that eric tried to put a bash expression in there, that's not how it works

Daniel Jomphe21:04:35

The master is here now (I didn't remark your answers at the top-level)


haha, yeah, I was missing something like that wrapper, where I could run multiple commands easily, I forgot I could create a function at bb.edn


you can also use babashka.process/tokenize if you want to manually split a "shell" string


it supports double and single quotes mixed

Daniel Jomphe21:04:39

thanks for explanations; gotta take a look at tokenize in next bb.edn rampage session!

Daniel Jomphe21:04:35

Sorry to notify you, I wanted to bring back in this thread Michiel's answer for future reference in the thread (I added a link to the thread in our code's TODO!)

šŸ‘ 4

Don't know how I ended up so far back in the history. Waking up an old thread here: šŸ˜¬ It's a classic mistake that I have made countless times: When using any program that exec's binaries it is so easy to think that it is a shell interpreter. But don't forget that you can get around it by explicitly executing bash with -c parameter, and then provide the entire command as a single parameter following -c. When bash is doing the interpretation then you can use all expressions, job control, conditionals, and importantly, expansion of environment variables!

bb -o '(shell/sh "bash" "-c" "cd /tmp && ls")'
bb -o '(shell/sh "bash" "-c" "echo $BASH_VERSION")'


Also, the original IOException error above - "cd" is not an executable program but just a built in command that bash interprets.


In bb you do this via the :dir option: (shell {:dir "/tmp"} "ls")

āœ… 1

@ericdallo shell != bash , so cd foo && ... isn't supported, but you can do it like this:

(shell {:dir "server"} "clojure -M:test")
;; or 
(clojure {:dir "server"} "-M:test")


I see! the former sounds good, will try


it works, thank you!

šŸŽ‰ 2

@ericdallo it also supports :extra-env {"FOO" "BAR"} - all the options from babaskha.process basically

šŸ’Æ 1

is there any built-in integration with


I'm doing this:

deploy-clojars-server (shell {:dir "server"} "clojure -T:build deploy-clojars")


I was thinking, maybe there is some function, like (tools/build "deploy-clojars")


that sounds awesome, not sure is possible tho, also one more deps to bb


I have 6 tasks on my bb.edn doing something like that


I can always create a function, but I thought it would be a convenient built-in


@ericdallo it doesn't have that. There is however, tools.bbuild which allows you to use natively ;)


hahah that looks nice, but I would like to keep all build logic on a build.clj still, is that possible?


There is also which has the neil add build command which installs a default build.clj file for you


Yes of course, it doesn't matter where you put that code


oh, I can just require it you mean from a local build.clj?


tools.bbuild is meant to be used with babashka and is considered experimental


oh, acutally bb tasks support namespaces


will give it a try


but in general you can just use on the JVM and use shell or clojure in bb tasks to invoke it


(clojure "-T:build uberjar")


yeah, but if I had bb speed that would be super cool :)


ok, then tools.bbuild is the thing to try :)


yeah, will try and let you know!


tools.bbuild is such a good name šŸ˜‚

Daniel Gerson11:05:00

I love that I went looking for bb and and tools.bbuild already exists partyparrot šŸ™Œ Agree the name is great!