babashka

Ben Sless 2025-05-20T07:14:59.017199Z

Maybe it has been asked before but regarding task execution, how can I run a shell command referencing an autocomplete resolution that has been installed by a third party tool? (specifically sdkman)

borkdude 2025-05-20T07:28:27.889889Z

you would like to capture the output right? often such tools write it to stderr, so you could do something like this:

(-> (shell {:err :string} "the-auto-complete-command) :err) 
If the auto-complete command writes to stdout instead, you should swap the :err key with :out

Ben Sless 2025-05-20T07:28:46.210289Z

I don't need to capture the output

Ben Sless 2025-05-20T07:29:34.927629Z

26: (shell "sdk" "selfupdate"))) sdkman:update
    ^--- Cannot run program "sdk": error=2, No such file or directory

borkdude 2025-05-20T07:29:55.319899Z

ok, sdk is a zsh function or so?

Ben Sless 2025-05-20T07:30:07.753459Z

no, it's a bash autocompletion base

complete -o default -F _sdk sdk

Ben Sless 2025-05-20T07:30:35.872889Z

I have no idea why it was not defined as a function or a bin

borkdude 2025-05-20T07:30:52.675189Z

but what are you trying to do, get autocompletions or run the sdk command?

Ben Sless 2025-05-20T07:30:59.867459Z

run it

borkdude 2025-05-20T07:32:04.059689Z

I think you should run it through your shell like this:

(shell (System/getenv "SHELL") "-c" "sdk")

borkdude 2025-05-20T07:32:13.431249Z

not sure if "-c" is the same for every shell

Ben Sless 2025-05-20T07:33:36.829619Z

invoking it like that does not load the .*rc file, right?

borkdude 2025-05-20T07:34:15.255809Z

don't know. perhaps it helps to write a separate script which sources the sdk stuff and then runs the command

borkdude 2025-05-20T07:34:23.953929Z

and then execute that script instead

Ben Sless 2025-05-20T07:34:47.342369Z

hmm. frustrating. not your fault, though, it's sdkman being creative

borkdude 2025-05-20T07:37:09.656059Z

that worked for me:

user=> (babashka.process/shell "zsh" "-c" "source \"$HOME/.sdkman/bin/sdkman-init.sh\" && sdk version")

SDKMAN!
script: 5.19.0
native: 0.7.4 (macos aarch64)

Ben Sless 2025-05-20T07:42:42.426819Z

no idea why my version couldn't run source

judepayne 2025-05-20T07:49:13.247939Z

I would like to use some Clojure code I've written from Python. Trying to think, would it be a worthwhile exercise for me to port the pods library to Python so that I can use any pod from Python? Certainly fun, but would like opinions on whether worthwhile/ generally useful?

judepayne 2025-06-17T06:30:23.882979Z

@borkdude Here it is; python-pods: https://github.com/judepayne/python-pods Please have a quick look, then I will announce it on this channel. It was a fun project!

borkdude 2025-05-20T08:33:35.444589Z

Sure why not :)

judepayne 2025-05-20T08:40:59.191319Z

lol. ok!

borkdude 2025-05-20T08:44:04.626109Z

I did a bit of searching and I found that someone has done an elixir port of pods here: https://hexdocs.pm/pods/1.0.0/examples.html

judepayne 2025-05-20T08:48:31.211279Z

Thanks will take a look this evening. There’s also this: https://github.com/Rohan2002/pypods but this is a port of the idea of pods and can only run python as a way of controlling dependencies. I am more interested in a faithful port

borkdude 2025-06-17T07:58:15.468929Z

that's very cool!

judepayne 2025-06-17T08:55:25.149299Z

😀 golang next at some point over the summer. If this library gets to 20 stars, there's one PR that babashka pods could use; Allowing for code strings (edn readers and functions that return "code") in maps

judepayne 2025-06-17T08:56:05.541479Z

{:py "the python code for this", :clj "the clojure code for this}. This would be backwards compatible

borkdude 2025-06-17T08:59:41.565229Z

makes sense. how did you now solve it when a pod uses "code" that returns clojure code?

2025-05-20T14:46:15.205929Z

Babashka is amazing with AI agents to develop Clojure. It lets them run tests or an ephemeral repl almost instantly.

🎉 3
dpsutton 2025-05-20T16:30:09.327569Z

I had a vague memory that (throw (ex-info "Criterion not satisfied" {:babashka/exit 1})) was a thing but couldn’t find it in the babashka book. Ultimately found it a few pages back in search here in slack. This will let us remove some (System/exit 1)s that we have in some functions which I’m a huge fan of. But they didn’t implement it that way due to discoverability. So i guess this is just feedback to document this somewhere the next time someone is editing the book or other docs

1
borkdude 2025-05-20T16:31:23.893719Z

Github issue welcome

dpsutton 2025-05-20T16:31:37.345619Z

on it. thanks!

dpsutton 2025-05-20T16:32:04.358099Z

bug report or feature request? blank?

borkdude 2025-05-20T16:35:23.554589Z

https://github.com/babashka/book

dpsutton 2025-05-20T16:35:40.669189Z

ah! right. i was doing it against babashka itself. thanks

dpsutton 2025-05-20T16:39:05.233629Z

https://github.com/babashka/book/issues/81

2025-05-20T16:34:26.688689Z

Bug? In clojure, a record with :type metadata will return the value from the metadata when called with type, but in bb it will return the record. (In other words, :type has priority in clojure)

✅ 1
borkdude 2025-05-20T20:19:11.788909Z

seems like a bug. where did you run into it? can you post an issue?

2025-05-21T11:59:36.155659Z

I was just playing around trying some things... Nothing critical. I created the issue: https://github.com/babashka/babashka/issues/1822

2025-05-21T12:32:56.913109Z

Already fixed... you're a machine! 😄