This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-07
Channels
- # announcements (5)
- # asami (17)
- # aws (11)
- # babashka (67)
- # beginners (90)
- # calva (13)
- # cider (17)
- # circleci (6)
- # clj-kondo (3)
- # clojure (53)
- # clojure-europe (12)
- # clojure-france (8)
- # clojure-germany (3)
- # clojure-losangeles (1)
- # clojure-nl (4)
- # clojure-norway (4)
- # clojure-spec (15)
- # clojure-uk (8)
- # clojurescript (41)
- # cursive (7)
- # data-science (6)
- # datomic (8)
- # emacs (10)
- # exercism (1)
- # figwheel-main (2)
- # fulcro (5)
- # graalvm-mobile (97)
- # graphql (1)
- # hyperfiddle (7)
- # inf-clojure (6)
- # interop (4)
- # introduce-yourself (5)
- # jobs (3)
- # kaocha (3)
- # malli (8)
- # meander (8)
- # music (3)
- # nrepl (7)
- # observability (1)
- # off-topic (45)
- # overtone (2)
- # polylith (63)
- # portal (2)
- # re-frame (26)
- # reveal (8)
- # ring (3)
- # shadow-cljs (56)
- # tools-build (5)
- # vim (11)
- # xtdb (8)
Have you seen the new GitHub Action https://github.com/DeLaGuardo/setup-clojure/releases/tag/5.0 v5 with bb support? I'm happy, it becomes easy to use most clojure tools.
In some GitHub actions, though, I install https://github.com/borkdude/deps.clj instead of those tools (see thread for how I do it). I then don't need to install Java to power Clojure.
- name: Install deps.clj, posing as clojure
run: |
# bash script below
Bash script to be run:
latest_release="$(curl -sL )"
download_url=""
echo -e "Downloading $download_url."
curl -o "deps.clj-$latest_release-linux-amd64.zip" -sL ""
unzip -qqo "deps.clj-$latest_release-linux-amd64.zip"
rm "deps.clj-$latest_release-linux-amd64.zip"
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
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.
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? š
Yeah, I'd expect deps
to be e.g. 20 MB and bb
e.g. 80 MB š
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 https://ruby-doc.org/stdlib-3.1.1/libdoc/pstore/rdoc/PStore.html
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. https://www.npmjs.com/package/keyv - but we could also easily make a pod around something like this probably from the golang side.
E.g. a pod around https://dbdb.io/db/boltdb
Existing storage solutions: ⢠https://github.com/babashka/pod-registry/blob/master/examples/datalevin.clj ⢠https://github.com/babashka/pod-registry/blob/master/examples/go_sqlite3.clj ⢠https://github.com/babashka/pod-registry/blob/master/examples/stash.clj
all very true!
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
it might even be a fun little project
Has anyone tried one of the file-backed atom/agent/ref libs with bb
?
https://github.com/jimpil/duratom
https://github.com/riverford/durable-ref
https://github.com/polygloton/durable-atom
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 --------------------------------------------------------------------
Type: java.io.IOException
Message: Cannot run program "cd": error=2, No such file or directory
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 ...
:)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")
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)
(println)
(apply shell args)))
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!
the issue was that eric tried to put a bash expression in there, that's not how it works
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
thanks for explanations; gotta take a look at tokenize in next bb.edn rampage session!
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!) https://clojurians.slack.com/archives/CLX41ASCS/p1649367592881239 https://clojurians.slack.com/archives/CLX41ASCS/p1649367701554329
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.
@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")
@ericdallo it also supports :extra-env {"FOO" "BAR"}
- all the options from babaskha.process basically
I'm doing this:
:tasks{
deploy-clojars-server (shell {:dir "server"} "clojure -T:build deploy-clojars")
}
@ericdallo it doesn't have that. There is however, tools.bbuild which allows you to use tools.build natively ;) https://github.com/babashka/tools.bbuild
hahah that looks nice, but I would like to keep all build logic on a build.clj still, is that possible?
There is also https://github.com/babashka/neil which has the neil add build
command which installs a default tools.build build.clj file for you
but in general you can just use tools.build on the JVM and use shell
or clojure
in bb tasks to invoke it
I love that I went looking for bb
and tools.build
and tools.bbuild
already exists š Agree the name is great!