Fork me on GitHub
#babashka
<
2022-05-10
>
Christian Pekeler08:05:18

We’re using babashka for the deployment script of our Clojure project, i.e. we have our-project/bin/deploy.clj that starts with #!/usr/bin/env bb. If this was in nodejs land, I’d add babashka as a dev-dependency to my project so that npm i would install babashka locally to my project and make the bb-executable available within the project. Is there something similar that I could do in Clojure land, so I wouldn’t have to require every collaborator to first do a global install of babashka on their machine?

borkdude08:05:17

@christian239 Babashka is probably more comparable to Node.js or Clojure itself than a library you would install with npm. But you could do:

bash <(curl ) --dir .
which downloads a copy of bb to the local directory

👍 1
borkdude08:05:07

Also a package manager like asdf or nix could perhaps help

👍 1
whacked10:05:00

babashka was added to nixpkgs relatively recently, I was so happy

Karol Wójcik08:05:04

@borkdude would it be possible to specify an architecture for which pods should be downloaded?

borkdude08:05:52

@karol.wojcik Perhaps this is possible using bb -Dos.arch=aarch64 but no guarantees :)

borkdude09:05:01

I tested that, but did not work

borkdude09:05:26

If we would support this, then we would also have to include the os + arch into the directory structure to prevent clashes, currently that's not the case

borkdude09:05:15

We already have:

prepare                       Download deps & pods defined in bb.edn and cache their metadata. Only an optimization, this will happen on demand when needed.

borkdude09:05:33

We could specify to download a specific OS as an option to that thing

borkdude09:05:45

Please make an issue for the above, if you're still interested.

borkdude16:05:49

That isn't about depependency resolution but about a different issue. Babashka cannot load Java classes that are not built-in at compile time.

👍 1
pavlosmelissinos16:05:45

Sorry if the answer is obvious but I'm having some trouble finding the answer. In https://book.babashka.org/#_running_a_script the example prints everything in the terminal. So if I do this:

export some_var=`./download_html.clj  /tmp/clojure.org.html`
echo $some_var
, the result is: > Downloading url: https://www.clojure.org > Writing file: /tmp/clojure.org.html What should I do if I just want the return value (the result of the last expression)? Is there something I can do on the babashka side or should I just replace printlns with logs and make sure they're sent to stderr or something? The use case is multiple babashka scripts running independently one after the other, each piping its result to the next one (our CI workflow is becoming too complex so I'm testing the waters with babashka; so far I'm very happy with it! ❤️).

Bob B16:05:15

Piping is sort of dependent on stdout and stdin, so you'd want to make the prints to stdout only the essential thing(s). However, babashka.process supplies some niceities for working with calls out to processes, so you could add in some "interceptors" if you wanted. Another alternative would be babashka tasks, which is sort of like make with separate tasks, dependencies between tasks, and so on. With tasks, you could print stuff and have a separate return value (that is, you could print from tasks and have a return value from a shell call or something). (<https://book.babashka.org/#tasks>)

pavlosmelissinos16:05:46

I'll check those out, thanks 🙂