babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
crimeminister 2020-12-23T00:39:30.365400Z

Hey folks, before I open an issue, has anyone else encountered this when using bb v0.2.5?

19:35 $ bb
Babashka v0.2.5 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (require '[babashka.curl])
nil
user=&gt; (curl/get "<http://example.com>")
Segmentation fault (core dumped)
The backtrace looks like:
(gdb) bt
#0  0x00007ffff4c5496e in nss_getline (line=0x7ffff5a004a0 "passwd:         compat systemd") at ../include/ctype.h:41
#1  nss_parse_file (fname=0x7ffff4cc75b7 "/etc/nsswitch.conf") at nsswitch.c:584
#2  __GI___nss_database_lookup2 (database=database@entry=0x7ffff7f9904f "passwd_compat", alternate_name=alternate_name@entry=0x0, 
    defconfig=defconfig@entry=0x7ffff7f99000 "nis", ni=ni@entry=0x7ffff7f9b390 &lt;ni&gt;) at nsswitch.c:127
#3  0x00007ffff7f93740 in init_nss_interface () at nss_compat/compat-pwd.c:94
#4  0x00007ffff7f956b5 in _nss_compat_getpwuid_r (uid=1000, pwd=0x48d9560, buffer=0x48ee8d0 "\250\061\215\004", buflen=1024, errnop=0x48db848)
    at nss_compat/compat-pwd.c:1064
#5  0x000000000221dcda in getpwuid_r ()
#6  0x000000000221dab4 in getpwuid ()
#7  0x000000000095e5f2 in ?? ()
...
Thanks!

borkdude 2020-12-23T09:58:34.366100Z

Perhaps the static compiled one? Don't use it if you don't have to

crimeminister 2020-12-24T01:15:12.379100Z

It likely was the statically compiled one, I'll try again otherwise and see what happens. Thanks for the suggestion!

borkdude 2020-12-23T07:59:38.365800Z

What bb binary did you download?

slipset 2020-12-23T17:15:44.368Z

For Reasons(TM) I wanted to have bb be part of my circle ci environment. Of course, I’m stuck on how to install bb in circle. Yes, it’s most likely me, but any help on how to make bb available during my circle jobs would be really appreciated.

slipset 2020-12-23T17:16:17.368500Z

The bash wget thingy fails with a missing filedescriptor.

lukasz 2020-12-23T17:17:40.369100Z

Not using bb in circle, but we just straight up curl -L via GH release urls

slipset 2020-12-23T17:26:08.369400Z

Thanks! that worked.

slipset 2020-12-23T17:26:25.369700Z

- run:
         name: Install babashka
         command: |
            curl -L --output bb.zip <https://github.com/borkdude/babashka/releases/download/v0.2.5/babashka-0.2.5-linux-amd64.zip>
            unzip bb.zip
            chmod a+x bb

slipset 2020-12-23T17:26:42.370Z

Please don’t get me started on how much I love yaml…

lukasz 2020-12-23T17:57:47.370500Z

Yep,also you can leverage Circle's cache and not download the file on each run

borkdude 2020-12-23T18:09:25.371900Z

@slipset babashka also has an install script: https://raw.githubusercontent.com/borkdude/babashka/master/install It supports a --version argument if you want to lock the version

borkdude 2020-12-23T18:09:49.372400Z

but curl and unzip is fine too

borkdude 2020-12-23T18:09:58.372900Z

and btw, you can generate the yaml from edn with babashka too ;)

slipset 2020-12-23T18:09:58.373Z

That’s what I tried first, but it failed on circle. Maybe /tmp is not available on circle?

lukasz 2020-12-23T18:11:18.373800Z

each run is in a separate container I believe, and only cached storage is shared

borkdude 2020-12-23T18:11:32.374100Z

makes sense. in clj-kondo that is configurable too: https://github.com/borkdude/clj-kondo/blob/0d31f63e40f220dff88670335ad639d39647314c/script/install-clj-kondo#L18 should probably copy that

lukasz 2020-12-23T18:12:57.374800Z

sorry - I need to clarify, you can write to tmp, but you also instruct circle to persist paths in cache and restore it

lukasz 2020-12-23T18:13:01.375100Z

it's a bit fiddly to be honest

lukasz 2020-12-23T18:13:50.375600Z

here's how we're caching maven deps: https://github.com/nomnom-insights/nomnom.bunnicula/blob/master/.circleci/config.yml#L23-L35 - similar mechanism works for anything

borkdude 2020-12-23T18:31:26.376700Z

@slipset I now added the --download-dir option to the script: https://raw.githubusercontent.com/borkdude/babashka/master/install E.g.:

./install --dir . --version 0.2.5 --download-dir . 
should work

slipset 2020-12-23T18:39:02.377Z

Thanks!

slipset 2020-12-23T18:43:37.377400Z

My first bb script https://github.com/slipset/cautious-engine/blob/main/.circleci/maybe-deploy.bb

👍 1
slipset 2020-12-23T18:50:27.377800Z

And 🙂

#!/bin/bash -eo pipefail
bash &lt;(curl -s <https://raw.githubusercontent.com/borkdude/babashka/master/install>) --dir . --download-dir .
Downloading <https://github.com/borkdude/babashka/releases/download/v0.2.5/babashka-0.2.5-linux-amd64.zip> to .
Successfully installed bb in ..
CircleCI received exit code 0

🎉 1
slipset 2020-12-23T18:50:36.378100Z

Thanks for the quick turnaround!

lukasz 2020-12-23T19:08:09.378800Z

@slipset ha, we have exactly the same script in bash because Circle cannot do conditional step runs

slipset 2020-12-23T20:55:31.379Z

@lukaszkorecki so do we 🙂