babashka

https://github.com/babashka/babashka. Also see #sci, #nbb and #babashka-circleci-builds .
Jakub Holý 2021-03-19T08:45:46.061700Z

Any plans to add generators to spartan spec? I see there is already clojure.test.generators in bb.... ?

borkdude 2021-03-19T08:53:09.061800Z

@holyjak Feel free to try to add them.

1
borkdude 2021-03-19T09:00:11.062500Z

@holyjak There is also a library called https://github.com/green-coder/minimallist which should support generators, should also work with bb

❤️ 1
borkdude 2021-03-19T09:00:21.062900Z

I didn't test it though

Dominik Mohilo 2021-03-19T10:08:10.065500Z

Hi Gentlepeople, my name is Dominik Mohilo and I am editor for the GERMAN Java Magazine 🙂 I am looking for someone (apart from Mr. borkdude 😉 ) that would like to write an article (deadline. 16th of April) about Babashka for our German audience. Obviously it would be preferred when the article would be written in German, but this is not a must 🙂 Please write me a direct message or an email via <mailto:dmohilo@sandsmedia.com|dmohilo@sandsmedia.com> if you would be able to keep the deadline and are interested in writing 🙂 Hit me also up, if you'd be interested to write about Clojure in the future or about another topic 🙂 Cheers,

❤️ 2
pez 2021-03-19T10:51:51.066600Z

Hopefully it will be written in English and published somewhere in that shape. 😃

1
Dominik Mohilo 2021-03-19T11:08:56.067200Z

We will definitely publish the English version, too 😉

Dominik Mohilo 2021-03-19T11:09:17.067700Z

Just not in printed form, unfortunately, but the most likely place for it would be http://jaxenter.com 🙂

❤️ 1
borkdude 2021-03-19T11:27:03.068Z

Idea for bb.edn: https://github.com/babashka/babashka/discussions/757#discussioncomment-502805 Feel free to comment.

grzm 2021-03-19T15:38:50.072900Z

Hola! I’ve got a cljc file that has babashka sections and jvm-clojure forms, and clj-bb-common forms that include symbols like *err* and pmap that aren’t available in cljs, so clj-kondo (and by extension clojure-lsp) complain about unresolved symbols. I’m not interested in using this namespace from cljs as all. What’s the common way of making the linter happy in these cases?

borkdude 2021-03-19T16:10:22.074500Z

@grzm Good question. Can you try :cljc {:features [:clj]} in your config? I am experimenting with this, it's still undocumented and might change.

borkdude 2021-03-19T16:11:17.074900Z

I am using it in babashka/fs myself

grzm 2021-03-19T16:12:04.075300Z

To confirm, in the clj-kondo config?

borkdude 2021-03-19T16:12:11.075500Z

yes

borkdude 2021-03-19T16:12:35.075700Z

This will cause the linter to ignore :cljs branches

grzm 2021-03-19T16:12:53.075900Z

oh, nice.

grzm 2021-03-19T16:16:26.076300Z

Yup, that works!

grzm 2021-03-19T16:16:30.076500Z

Cheers!

grzm 2021-03-19T16:18:00.076700Z

Looks like it clears it up the emacs/clojure-lsp, too. So clojure-lsp is .clj-kondo/config.edn aware?

borkdude 2021-03-19T16:19:37.077Z

yes, it uses clj-kondo for its analysis

grzm 2021-03-19T16:22:31.077200Z

Nice to confirm that the local config gets picked up, too. Thanks!

grzm 2021-03-19T16:56:52.079100Z

Are there known issues using babaska pods on NixOS? I’m able to use pods on macOS but not NixOS. I can investigate further, but I wanted to know if this is a known issue before diving in.

grzm 2021-03-19T16:57:08.079200Z

On macOS:

bb
Babashka v0.2.8 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=&gt; (require '[babashka.pods :as pods])
nil
user=&gt; (pods/load-pod 'org.babashka/aws "0.0.5")
#:pod{:id "pod.babashka.aws.credentials"}
user=&gt; 

grzm 2021-03-19T16:58:28.079500Z

On NixOS:

λ bb
Babashka v0.2.8 REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=&gt; (require '[babashka.pods :as pods])
nil
user=&gt; (pods/load-pod 'org.babashka/aws "0.0.5")
java.io.IOException: Cannot run program "/home/mglaesemann/.babashka/pods/repository/org.babashka/aws/0.0.5/pod-babashka-aws": error=2, No such file or directory [at &lt;repl&gt;:2:1]
user=&gt; 
λ ls -la /home/mglaesemann/.babashka/pods/repository/org.babashka/aws/0.0.5/pod-babashka-aws
-rwxr--r-- 1 mglaesemann cloud_users 99238904 Mar  2 00:19 /home/mglaesemann/.babashka/pods/repository/org.babashka/aws/0.0.5/pod-babashka-aws

borkdude 2021-03-19T16:59:25.079900Z

these pods are dynamically linked. Maybe you are missing libc++?

grzm 2021-03-19T16:59:39.080100Z

That could be. I’ll track that down.

grzm 2021-03-19T16:59:55.080300Z

Cheers!

borkdude 2021-03-19T17:00:19.080500Z

on the other hand, if bb itself runs, then the pod should also run I think

borkdude 2021-03-19T17:00:32.080900Z

unless bb was built statically

wilkerlucio 2021-03-19T17:00:50.081400Z

I'm trying to make a small http-server using http-kit and babashka, but the process is quitting, how do I keep babashka alive?

borkdude 2021-03-19T17:01:05.081700Z

@wilkerlucio @(promise) is what I usually do

💯 3
grzm 2021-03-19T17:02:11.081800Z

Looks like we’re using the dynamic release.

grzm 2021-03-19T17:02:59.082100Z

babashka-0.2.8-linux-amd64.zip

borkdude 2021-03-19T17:03:24.082300Z

what happens if you run /home/mglaesemann/.babashka/pods/repository/org.babashka/aws/0.0.5/pod-babashka-aws directly?

grzm 2021-03-19T17:06:41.082600Z

Well, isn’t this interesting:

λ ls -la /home/mglaesemann/.babashka/pods/repository/org.babashka/aws/0.0.5/pod-babashka-aws
-rwxr--r-- 1 mglaesemann cloud_users 99238904 Mar  2 00:19 /home/mglaesemann/.babashka/pods/repository/org.babashka/aws/0.0.5/pod-babashka-aws
17:05 mglaesemann@pair: ~
λ /home/mglaesemann/.babashka/pods/repository/org.babashka/aws/0.0.5/pod-babashka-aws
-bash: /home/mglaesemann/.babashka/pods/repository/org.babashka/aws/0.0.5/pod-babashka-aws: No such file or directory
17:05 mglaesemann@pair: ~[127]

grzm 2021-03-19T17:07:16.082900Z

Someone’s lying to me.

grzm 2021-03-19T17:07:33.083100Z

Something else for me to track down.

borkdude 2021-03-19T17:07:44.083300Z

This is a message you get when the dynamically linked library cannot be found I think

borkdude 2021-03-19T17:08:17.083500Z

I think you can see the list of required libs with ldd

borkdude 2021-03-19T17:08:55.083700Z

$ ldd $(which bb)
	linux-vdso.so.1 (0x00007ffebb7c3000)
	libstdc++.so.6 =&gt; /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f4177d5f000)
	libm.so.6 =&gt; /lib/x86_64-linux-gnu/libm.so.6 (0x00007f4177bdc000)
	libpthread.so.0 =&gt; /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f4177bbb000)
	libdl.so.2 =&gt; /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f4177bb6000)
	libz.so.1 =&gt; /lib/x86_64-linux-gnu/libz.so.1 (0x00007f4177998000)
	librt.so.1 =&gt; /lib/x86_64-linux-gnu/librt.so.1 (0x00007f417798e000)
	libc.so.6 =&gt; /lib/x86_64-linux-gnu/libc.so.6 (0x00007f41777cb000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f417cd23000)
	libgcc_s.so.1 =&gt; /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f41777b1000)

grzm 2021-03-19T17:09:00.083900Z

λ ldd /home/mglaesemann/.babashka/pods/repository/org.babashka/aws/0.0.5/pod-babashka-aws
	linux-vdso.so.1 (0x00007ffffed1c000)
	libstdc++.so.6 =&gt; not found
	libpthread.so.0 =&gt; /nix/store/33idnvrkvfgd5lsx2pwgwwi955adl6sk-glibc-2.31/lib/libpthread.so.0 (0x00007f094aea4000)
	libdl.so.2 =&gt; /nix/store/33idnvrkvfgd5lsx2pwgwwi955adl6sk-glibc-2.31/lib/libdl.so.2 (0x00007f094ae9f000)
	libz.so.1 =&gt; not found
	librt.so.1 =&gt; /nix/store/33idnvrkvfgd5lsx2pwgwwi955adl6sk-glibc-2.31/lib/librt.so.1 (0x00007f094ae95000)
	libc.so.6 =&gt; /nix/store/33idnvrkvfgd5lsx2pwgwwi955adl6sk-glibc-2.31/lib/libc.so.6 (0x00007f094acd6000)
	/lib64/ld-linux-x86-64.so.2 =&gt; /nix/store/33idnvrkvfgd5lsx2pwgwwi955adl6sk-glibc-2.31/lib64/ld-linux-x86-64.so.2 (0x00007f0950d4c000)
17:08 mglaesemann@pair: ~

borkdude 2021-03-19T17:09:10.084100Z

yeah, so it's libstdc++

grzm 2021-03-19T17:09:34.084300Z

λ ldd $(which bb)
	linux-vdso.so.1 (0x00007fff895ad000)
	libstdc++.so.6 =&gt; /nix/store/hxs99j1kx878pxxw5lbdarml69r5f1qb-gcc-9.3.0-lib/lib/libstdc++.so.6 (0x00007fcee1fd8000)
	libpthread.so.0 =&gt; /nix/store/33idnvrkvfgd5lsx2pwgwwi955adl6sk-glibc-2.31/lib/libpthread.so.0 (0x00007fcee1fb7000)
	libdl.so.2 =&gt; /nix/store/33idnvrkvfgd5lsx2pwgwwi955adl6sk-glibc-2.31/lib/libdl.so.2 (0x00007fcee1fb2000)
	libz.so.1 =&gt; /nix/store/z39zr65hrbimzh40mxmdbpz64ma4b5vy-zlib-1.2.11/lib/libz.so.1 (0x00007fcee1f95000)
	librt.so.1 =&gt; /nix/store/33idnvrkvfgd5lsx2pwgwwi955adl6sk-glibc-2.31/lib/librt.so.1 (0x00007fcee1f8b000)
	libc.so.6 =&gt; /nix/store/33idnvrkvfgd5lsx2pwgwwi955adl6sk-glibc-2.31/lib/libc.so.6 (0x00007fcee1dca000)
	libm.so.6 =&gt; /nix/store/33idnvrkvfgd5lsx2pwgwwi955adl6sk-glibc-2.31/lib/libm.so.6 (0x00007fcee1c89000)
	/nix/store/33idnvrkvfgd5lsx2pwgwwi955adl6sk-glibc-2.31/lib/ld-linux-x86-64.so.2 =&gt; /nix/store/33idnvrkvfgd5lsx2pwgwwi955adl6sk-glibc-2.31/lib64/ld-linux-x86-64.so.2 (0x00007fcee6c7c000)
	libgcc_s.so.1 =&gt; /nix/store/hxs99j1kx878pxxw5lbdarml69r5f1qb-gcc-9.3.0-lib/lib/libgcc_s.so.1 (0x00007fcee1c6f000)
17:09 mglaesemann@pair: ~

borkdude 2021-03-19T17:09:35.084500Z

but this is weird, since bb already uses that too

borkdude 2021-03-19T17:09:59.084700Z

maybe this is because you are using nix

borkdude 2021-03-19T17:10:04.084900Z

it has different dirs for every lib

grzm 2021-03-19T17:10:06.085100Z

Yeah, but there’s the whole Nix layering stuff going on, too. I’ll ask some of our nix gurus.

borkdude 2021-03-19T17:10:44.085300Z

this downloading of binaries is against the spirit of nix. maybe you should also build the pods using nix recipes. good luck ;)

grzm 2021-03-19T17:11:24.085600Z

Indeed 🙂 One more thing to ask the nix gurus about :rolling_on_the_floor_laughing: Or, of course, it could be a learning opportunity

Jakub Holý 2021-03-19T18:42:19.087600Z

Hi! Can I distinguish whether a bb script is run from the command line (`bb -f`) or inside repl? Python has a nice trick for that and I believed bb as well but cannot find it now... 🙏

✅ 1
nate 2021-03-19T18:43:21.087800Z

@holyjak https://book.babashka.org/#main_file

👍 1
Jakub Holý 2021-03-19T18:43:57.088400Z

thanks a ot!

grazfather 2021-03-19T18:51:36.089Z

How do I tell emacs that my file that starts with a shebang (for bb) is a clojure file>

borkdude 2021-03-19T18:53:06.089700Z

I don't know the solution in general though. why not just name it .clj?

borkdude 2021-03-19T18:53:31.090100Z

Or .bb and then configure clojure-mode to be activated on that extension as well

grazfather 2021-03-19T18:54:07.090300Z

because I want it on my PATH 🙂

borkdude 2021-03-19T18:55:13.090600Z

so? I have lots of .clj files on my PATH

grazfather 2021-03-19T18:55:23.090900Z

less typing

grazfather 2021-03-19T18:55:31.091200Z

hl is a lot shorter than hl.clj

grazfather 2021-03-19T18:55:46.091700Z

but the -*- thing works 🙂

grazfather 2021-03-19T18:56:30.092900Z

I knew that was a thing, I’ve seen it a ton but I didn’t know its syntax nor its name to google

borkdude 2021-03-19T18:57:26.093900Z

yeah, makes sense. I've been thinking about a task runner for bb projects. like:

bb hl
and then define in bb.edn:
{:tasks {hl {:task/type :babashka :args ["-f" "script/hl.clj"]}}}
but because I want to avoid conflicts with existing files, I am considering using keywords for task names:
bb :hl 
Would that be too ugly or awkward, or ok?

👀 1
grazfather 2021-03-19T18:58:00.094500Z

yep, I was just thinking of writing my own. I like the ‘subcommand’ style of clis

grazfather 2021-03-19T18:58:08.094900Z

bb :hl would be cool

borkdude 2021-03-19T18:58:43.095600Z

bb :hl -p "foo.bar"
I thought it would maybe be awkward since keywords are often expected to be used in k/v pairs

grazfather 2021-03-19T18:59:25.096Z

it is strange when edn-style keywords make it to the shell

grazfather 2021-03-19T18:59:46.096500Z

but i think it’s used in lein cli sometimes without a corresponding value?

borkdude 2021-03-19T19:00:11.096900Z

true, also (require [foobar] :reload) is without corresponding value.

borkdude 2021-03-19T19:00:39.097400Z

I think it would be kind of distinguishing to use keywords for this, since it's clear you are invoking a task

borkdude 2021-03-19T19:01:08.098Z

And I would then promote all of the other things to tasks as well:

bb :uberjar -m foo.bar

borkdude 2021-03-19T19:01:29.098300Z

instead of:

bb --uberjar -m foo.bar

grazfather 2021-03-19T19:02:23.098800Z

I am no UI expert but I prefer that

borkdude 2021-03-19T19:02:26.098900Z

maybe there can also be a built-in bb :test like lein test

borkdude 2021-03-19T19:02:37.099200Z

prefer that = which one?

grazfather 2021-03-19T19:02:40.099400Z

go run go build go env etc

grazfather 2021-03-19T19:02:53.099700Z

I am indifferent to whether : is in there

grazfather 2021-03-19T19:03:15.100200Z

but if it’s a ‘task’ and you can’t run more than one than I think it’s better without --

borkdude 2021-03-19T19:04:17.101200Z

there will also be a :do task which allows you to combine tasks, but the syntax for this is currently controversial:

bb :do :task1 arg1 arg2 :__ :task2 arg1 arg2

grazfather 2021-03-19T19:05:36.101400Z

why :__ as the delimiter?

borkdude 2021-03-19T19:05:59.101800Z

because I could not find another one, which one should I use?

grazfather 2021-03-19T19:06:04.102Z

I am not sure

grazfather 2021-03-19T19:06:31.102800Z

-- often separates arg opts from opts to the script

grazfather 2021-03-19T19:06:37.103100Z

i thought you were alluding to that

borkdude 2021-03-19T19:07:33.104200Z

lein uses:

lein do task1 arg1 arg2, task2 arg1 arg2
yes, I am alluding to that. but -- might already be used by tasks?

borkdude 2021-03-19T19:07:53.104700Z

as in task1 could also be using -- for its own parsing and then it would never see the remaining args?

borkdude 2021-03-19T19:08:01.105Z

or isn't this a problem...?

borkdude 2021-03-19T19:08:26.105200Z

maybe it isn't

borkdude 2021-03-19T19:08:43.105600Z

bb :do :task1 foo bar -- :task2 baz quuz ?

borkdude 2021-03-19T19:09:06.105800Z

could also use :--

grazfather 2021-03-19T19:09:57.106700Z

You definitely are in a weird spot: You’re nesting tasks that can have their own arg parsing delimiters

grazfather 2021-03-19T19:10:29.107Z

so pretend I write my own docker exec in bb

grazfather 2021-03-19T19:10:44.107400Z

You split the args from the container and the args to the exec

grazfather 2021-03-19T19:11:08.108200Z

docker exec -it --rm ubuntu -- bash -c "/bin/sh" (don’t ask why i’d run that)

grazfather 2021-03-19T19:11:10.108400Z

so

grazfather 2021-03-19T19:11:29.109200Z

bb :do :exec -it --rm ubuntu -- bash -c "/bin/sh" :-- ...

grazfather 2021-03-19T19:11:48.110Z

-- as task delimiter wouldn’t work there

borkdude 2021-03-19T19:12:15.110700Z

right {:docker {:task/type :shell :args ["docker exec"]}}

bb :do :docker -it --rm --ubuntu -- bash -c :-- :yolo

grazfather 2021-03-19T19:12:58.111300Z

:-- seems reasonable. Have you ever seen it used in other clj/lisp cli contexts?

grazfather 2021-03-19T19:13:14.111900Z

I think that basically you want something unique, obvious, and easy to type

borkdude 2021-03-19T19:13:18.112100Z

no, maybe in prismatic schema, but there it is :-

grazfather 2021-03-19T19:13:36.112400Z

cool

grazfather 2021-03-19T19:13:49.112900Z

but I would ask people who aren’t me ’cause I am new to clj/lisps

borkdude 2021-03-19T19:14:12.113400Z

someone also suggested: :--/ok and :--/continue to indicate continue even when the previous task failed

grazfather 2021-03-19T19:14:51.113600Z

hm

grazfather 2021-03-19T19:15:21.114300Z

or sacrifice that granularity (per task) and instead allow :cont as an arg taht must be before :do and apply it to each task

grazfather 2021-03-19T19:16:03.114700Z

or something make-like: if the :task is actually :-task or similar it means allow errors

grazfather 2021-03-19T19:17:25.114900Z

[graziano@gm-mbp:~/code/dotfiles/bin]$ make t
false
make: *** [t] Error 1
[graziano@gm-mbp:~/code/dotfiles/bin]$ make t2
false
make: [t2] Error 1 (ignored)
echo ok
ok
[graziano@gm-mbp:~/code/dotfiles/bin]$ \cat Makefile
t:
        false
        echo ok

t2:
        -false
        echo ok

borkdude 2021-03-19T19:18:32.115400Z

that will make parsing more awkward, I prefer something more explicit

borkdude 2021-03-19T19:18:46.115600Z

:-- I like

borkdude 2021-03-19T19:18:52.115900Z

and works for most cases

borkdude 2021-03-19T19:19:10.116500Z

and you can always use :--/continue if necessary

borkdude 2021-03-19T19:19:19.116900Z

(or some better name)

grazfather 2021-03-19T19:19:22.117Z

Yeah. I just don’t like ‘smuggling’ out bb task context args in the middle of task args

borkdude 2021-03-19T19:19:43.117200Z

smuggling?

grazfather 2021-03-19T19:19:59.117500Z

idk if that’s the best word

borkdude 2021-03-19T19:20:15.118100Z

I just don't understand what you didn't like. Be explicit please ;)

grazfather 2021-03-19T19:20:18.118300Z

if you think of like lexical contexts I guess :--/continue leaks out of the task context

grazfather 2021-03-19T19:20:56.119100Z

bb :do :task1 :t1a1 :-- :task2 :t2a1 :--/continue :-- :task3 :t2a1

borkdude 2021-03-19T19:21:28.119400Z

how so?

grazfather 2021-03-19T19:21:39.119700Z

between :task2 and :-- in my mind everything should apply to task2

borkdude 2021-03-19T19:21:55.120100Z

no, this would be:

bb :do :task1 :t1a1 :-- :task2 :t2a1 :--/continue :task3 :t2a1

borkdude 2021-03-19T19:22:14.120600Z

:--/continue is just a more special version of :--

grazfather 2021-03-19T19:22:15.120800Z

ahh, I guess that is obvious, I misunderstood 🙂

grazfather 2021-03-19T19:22:25.121Z

yeah, that seems a lot more reasonable

borkdude 2021-03-19T19:22:45.121300Z

from a distance, I'm not sure if this is too ugly though

grazfather 2021-03-19T19:23:04.121600Z

I don’t imagine it would be used a ton

grazfather 2021-03-19T19:23:45.122400Z

getting into the weeds, why / to delimit :-- from the ‘opt’?

borkdude 2021-03-19T19:24:08.122600Z

dunno :)

grazfather 2021-03-19T19:25:27.123100Z

we might be bike shedding

grazfather 2021-03-19T19:25:34.123300Z

you’re pre-1.0 for a reason

grazfather 2021-03-19T19:25:51.123800Z

if you choose one and people don’t like it, user your god given right to break backwards compatibility

borkdude 2021-03-19T19:26:53.124200Z

sure, but this is never a popular thing to do ;)

grazfather 2021-03-19T19:27:23.124500Z

yeah but I am shielded from that 😄

borkdude 2021-03-19T19:27:37.124900Z

maybe I'll just keep this tasks idea very very basic

borkdude 2021-03-19T19:27:48.125200Z

and then let it grow organically based on feedback

borkdude 2021-03-19T19:28:10.125500Z

but bb :task kind of felt good to me

grazfather 2021-03-19T19:28:51.125700Z

yeah true

grazfather 2021-03-19T19:28:54.125900Z

YAGNI is a good principle

borkdude 2021-03-19T19:30:57.126500Z

maybe there will be somebody who reads all of the tasks from bb.edn and generates bash stubs for those in a bin folder ;P

borkdude 2021-03-19T19:31:05.126700Z

so you can do $ task :P

grazfather 2021-03-19T19:31:14.127Z

💥