babashka

pez 2026-03-20T09:25:01.230629Z

What do people do for global bb tasks these days? I found a tip from @borkdude on ClojureVerse from a while ago, and did this. Works beautifully.

👀 1
🎉 1
2
pez 2026-03-20T09:28:29.662979Z

I’m not sure loc belongs as a global task, but I will try maintain it and see if it makes sense. From a project I care a lot about (yes, #epupp):

❯ bbg loc
     229 text files.
     206 unique files.                                          
      72 files ignored.

 v 2.00  T=0.13 s (1185.0 files/s, 290076.2 lines/s)
-------------------------------------------------------------------------------
Language                     files          blank        comment           code
-------------------------------------------------------------------------------
ClojureScript                  116           3820           2975          24617
CSS                              5            370            165           1983
JSON                             4              0              0           1794
Clojure                          7            109             71            981
HTML                            13             69             28            658
YAML                             3             62              5            337
ClojureC                         1             24              2            263
JavaScript                       5             28             62            168
SVG                              3              0              4             28
Dockerfile                       1             12             17             25
-------------------------------------------------------------------------------
SUM:                           158           4494           3329          30854
-------------------------------------------------------------------------------

pez 2026-03-20T15:22:52.995799Z

Completions, This gives me one-level options completion:

_bbg() {
    if (( CURRENT == 2 )); then
        local tasks=(`bbg tasks | tail -n +3 | cut -f1 -d ' '`)
        compadd -a tasks
    else
        local task="${words[2]}"
        local opts=(`bbg tasks | grep "^${task} " | grep -oE '\-\-[a-z-]+'`)
        if (( ${#opts} )); then
            compadd -a opts
        fi
    fi
}
compdef _bbg bbg
Given that the options are mentioned in the doc strings:
❯ bbg tasks            
The following tasks are available:

loc    Count lines of code (excludes generated files, markdown, vendor)
clj    Manage clojure installs. Options: --status, --update, --update-deps-clj, --use-deps-clj, --use-clojure
config Manage config repos. Options: --status, --save
java   Manage Java versions. Options: --status, --version <major|latest>

teodorlu 2026-04-10T08:23:16.221789Z

My current system sucks! I have some conventions around creating scripts with Babashka, prefixing executables with ,, and the collection here: https://github.com/teodorlu/shed So I would be happy to consider something different 😅 One observation: your approach would build a classpath with all the dependencies for all the tasks in order to execute any of the tasks. Not sure if that's a downside. It lets you work on all the tasks from within a single REPL. Perhaps that's just fine? Q: would having all global scripts go via babashka tasks prevent individual tasks from providing their own shell completion?

teodorlu 2026-04-10T08:24:20.227419Z

Nonetheless, I would love to have a nice collection of system-wide Babashka scripts that are easy to work on and easy to improve. Requirements for me: • No build step • Can work on scripts from the REPL as easily as run them

pez 2026-04-10T12:04:46.053169Z

I have updated the recipe a bit since I posted this. Using --config instead of mucking with the current directory. About the tab completion, that’s also a thing I do differently now. Local tasks have separate completion, if that’s what you wondered? Here’s my updated recipe, including some tasks: https://github.com/PEZ/my-bbg

👍 1
teodorlu 2026-04-10T12:23:24.360419Z

> Local tasks have separate completion, if that’s what you wondered? Yep, that was my concern! Thank you, I'll have a look!

2026-03-20T21:16:02.135679Z

Hi I try to use babashka.http to do some requests but as they are failing i probably made an error. Is it possible print out the exact request an (http/post ... ) makes. I'm running my code on babashka

borkdude 2026-03-20T21:17:01.643379Z

Yes there's a debug option for it

borkdude 2026-03-20T21:17:10.263759Z

I think

borkdude 2026-03-20T21:17:23.404459Z

Or Java net http has an option for it

2026-03-20T21:18:51.160579Z

In the documentation i found: "`-Djdk.httpclient.HttpClient.log=errors,requests,headers,frames[controldata:window:all..],content,ssl,trace,channel"` but as far as i can tell i can't add this option to an bb nrepl?

Bob B 2026-03-20T21:34:00.326459Z

a client can be passed as :client, or client can also be a function, so you can sort of skip actually making the request altogether:

user=> (babashka.http-client/get "" {:client identity :raw true})
{:client #object[clojure.core$identity 0x7c556abb "clojure.core$identity@7c556abb"], :raw true, :uri #object[java.net.URI 0x7be5084d ""], :method :get, :headers nil}
...whether that's useful or not will probably depend on the nature of the failure

2026-03-20T21:39:54.224589Z

yes it helped, i was interpreting the oauth options wrong and had a Bearer Bearer 🙂

2026-03-20T21:41:33.485209Z

@borkdude and @highpressurecarsalesm thanks for your help!

borkdude 2026-03-20T21:47:54.159319Z

Brilliant, we should document this ;)

borkdude 2026-03-20T21:48:34.198359Z

you can start the bb nrepl with this btw:

bb -Djdk.httpclient.HttpClient.log=... nrepl-server

👍 1
Bob B 2026-03-20T23:03:49.583749Z

regarding docs - I was mostly going off the http-client API doc, but I did notice that :raw is missing as an opt there. If I open a PR for doc updates, would you prefer just adding :raw ? How would you feel about a small example in the readme using identity or something as a client?

borkdude 2026-03-20T23:04:39.602859Z

oh sorry I didn't know it was already documented, responded from phone. all good then.

2026-03-23T08:01:16.924499Z

@borkdude i'm not able to run bb with the log statement: > ❯ bb -Djdk.httpclient.HttpClient.log=errors,requests,headers,frames[controldata:window:all..],content,ssl,trace,channel nrepl > zsh: no matches found: -Djdk.httpclient.HttpClient.log=errors,requests,headers,frames[controldata:window:all..],content,ssl,trace,channel

borkdude 2026-03-23T08:05:30.497529Z

You’re running into.a shell quoting issue or something. Is your argument on the same line? Anyway this is a zsh syntax problem

2026-03-23T08:11:52.665239Z

with bash i get a similar problem

bash-5.3$ bb -Djdk.httpclient.HttpClient.log=errors,requests,headers,frames[:control:data:window:all..],content,ssl,trace,channel nrepl
----- Error --------------------------------------------------------------------
Type:     java.lang.Exception
Message:  File does not exist: nrepl

2026-03-23T08:14:20.209409Z

Sorry it was a user error...

2026-03-23T08:14:40.558889Z

bb "-Djdk.httpclient.HttpClient.log=errors,requests,headers,frames[:control:data:window:all..],content,ssl,trace,channel" nrepl-server

👍 1
2026-03-23T08:14:44.336639Z

works fine