Fork me on GitHub
#babashka
<
2022-10-12
>
macrobartfast02:10:56

I curl installed bb but then saw it can be managed by brew… thoughts on which approach is better? If brew is better, can one go that route after the curl install?

lispyclouds02:10:21

bb gets installed by default to /usr/local/bin/bb if using the install script. simply removing that one file and doing a brew install should do it

lispyclouds02:10:36

bb is a single binary distribution

lispyclouds02:10:21

brew is better, specially on MacOS as you can manage updates in a cleaner more global way.

upvote 1
macrobartfast02:10:35

Will do. That’ll keep things more up to date too as brew tends to keep me more on the ball.

1
lispyclouds02:10:26

the install script is primarily targeted towards linux/unix users and things like CI or servers etc

macrobartfast02:10:21

It was worth it just to see how tiny the whole thing is… I was expecting a long download, out of habit, and it took about as long as running ls.

lispyclouds02:10:31

well the binary size is one of the most crucial aspects we try to control in bb. quite the factor when developing bb. pretty much you can see why 😄

👍 1
lispyclouds02:10:09

we have #CSDUA8S6B for dev builds, which also shows you how much the binary size is of every master commit 🙂

macrobartfast02:10:49

Forgive my ineptness… where do I see the size in those channel listings? Just curious how to interpret them. Is it the last number?

lispyclouds02:10:47

no worries! its that number you see here, in bytes

lispyclouds02:10:56

yeah the one after the commit hash

seancorfield05:10:07

I wasn't sure whether I felt 85MB was large or small. We're considering vendoring it into our repo at work but it will be the single largest file in git if we do. We already vendor in the entire Clojure CLI (the tools JAR is the only large file at 20MB) and an executable that powers our one remaining legacy app (46MB).

borkdude06:10:57

The zipped binary is around 25 mb. It’s still a bit smaller than Clojure-LSP

borkdude06:10:27

I wouldn’t put bb binaries into git personally. GitHub releases is where you can re-download it if you have to

seancorfield06:10:15

Then you need wrapper scripts that download the specified version which complicates dev/test/CI setup and deployment.

seancorfield06:10:36

So it's a tradeoff we've made on the above-mentioned binaries/JAR files.

seancorfield06:10:48

Knowing that /var/www/worldsingles/build/bin/whatever is always accessible and the correct version, without needing all tiers to be able to download new stuff on-demand is a big pro.

👍 1
borkdude06:10:21

That wrapper script we already have and supports a —version and —dir option

seancorfield06:10:39

Oh, what is that?

seancorfield06:10:21

Ah, you mean the install script could be under version control and you'd just run that first every time?

seancorfield06:10:46

That's sort of OK for CI but it sucks for anything else that you might want to build off it.

seancorfield06:10:58

Goal: run /path/to/some/script.clj that contains a shebang to use bb -- is there a command to substitute there for bb and have it auto-install/-update the bb executable and then run script.clj using that version of bb? That's the concrete case I'm talking about.

borkdude06:10:00

If it helps, bb.edn also supports :min-bb-version.

seancorfield06:10:35

It doesn't really since a lot of scripts aren't going to have that file around.

seancorfield06:10:57

If there was a bb.sh that auto-installed bb if it wasn't already present (or the right version) and then delegated to it, so you could have shebangs pointing at bb.sh and have everything "just work", that would be reasonable.

seancorfield06:10:40

That's essentially what Leiningen does with its self-install (and several other tools I've used over the years).

borkdude06:10:16

We don’t have that but I guess it would be handy to have in your setup and the installer script could be called from there

seancorfield06:10:32

On-demand, yes, so it would auto-install whatever version the script specified, if it wasn't already installed, and then just run as if it were the actual binary itself. Yeah, that would be nice. But having an 85MB binary in git isn't horrible 🙂

👍 1
lispyclouds06:10:19

If i remember it was Bitbucket CI right? Is it self hosted? Maybe bb can be built into the runner base image or something?

seancorfield19:10:21

BitBucket, yes, and we use clojure:temurin-18-tools-deps-1.11.1.1113 right now, but since we vendor the CLI ourselves, we could use a base Temurin image or indeed a Babashka image that also had a specified version of the JDK if such thing existed 🙂

seancorfield19:10:38

But that would still mean that other developers would have to install it themselves -- although we could vendor the installer into our repo and just run it in CI which wouldn't be a big deal really (and developers could run it whenever we vendor in a new version).

seancorfield19:10:23

Overall tho', having reviewed all our current shell scripts, there's not as much scope for converting things to bb as I'd initially hoped so this is all going to the backburner until we have more of an actual need (and since we run our build.clj as a REPL for a lot of stuff, the startup time isn't really an issue, although we do run a lot of tasks in subprocesses right now, since most of those fire up clojure or java processes anyway -- but those likely couldn't run as bb scripts).

borkdude19:10:04

Makes sense!

borkdude20:10:41

One more idea, since you're checking the bb binary into git. If you don't care about 250ms extra startup time, you may want to compress bb with upx: https://upx.github.io/ Which makes it the size of the original zip again and it will uncompress when you execute bb (which does take some CPU, but maybe not so much). I'm not using this myself because I prefer faster startup and don't check "large" binaries into git, but for your workflow this may be relevant.

seancorfield20:10:48

Interesting, thanks. At this point -- with no real "need" for bb -- we're not putting it in the repo, but will bear that in mind for the future.

macrobartfast02:10:57

And thank you for babashka!

👍 2
mkvlr08:10:33

with clj -X I can override the the :exec-fn set in my alias by passing it as first arg. babashka.cli does not support this, correct?

borkdude08:10:56

@U5H74UNSF bb -x supports this

mkvlr08:10:05

but clj -M:,,, does not?

borkdude08:10:49

aha... yeah, I think that can be fixed

borkdude08:10:52

issue welcome!

mkvlr08:10:19

another question if I may: is there a way to figure out how I was called (`-X` vs -M?)

mkvlr08:10:51

I want to support printing https://github.com/babashka/cli#help when called via -M

borkdude08:10:13

@U5H74UNSF You can print help regardless of -X / -M?

borkdude08:10:36

e.g. clojure -X :help true could also print help

mkvlr08:10:46

but I'd like to print it differently?

mkvlr08:10:04

-X would need a different help then -M?

borkdude08:10:16

I'll check in a minute, first trying to solve your first issue

borkdude10:10:29

I fixed the first issue but something went wrong on CI, just a minute

borkdude10:10:43

@U5H74UNSF Second issue: v0.5.40 • Add :org.babashka/cli {:exec true} to arg map's metadata when invoking functions with babashka.cli.exec.

borkdude10:10:48

This is how you can check it now

mkvlr10:10:30

@U04V15CAJ thank you! 🙏🙏🙏

🎉 1
mkvlr10:10:52

v0.5.40 isn't on maven yet: org.babashka:cli:jar:0.4.40 my bad!

borkdude21:10:57

❤️ 6
🎉 2