babashka

borkdude 2025-09-23T08:58:18.001019Z

https://zenn.dev/tkmfujise/articles/7eebdf57ae9fc3

πŸ™‡ 1
πŸ”₯ 6
πŸ‡―πŸ‡΅ 5
vemv 2025-09-23T16:31:15.671609Z

Given a monorepo with many bb.edns within it, what would be an idiomatic way to resuse some defns across them? (e.g. put them somewhere at the monorepo root) I'd be seeking something lightweight, no installation steps or versioning involved

borkdude 2025-09-23T16:53:17.785289Z

Make a small lib with :local/root

1
vemv 2025-09-23T17:07:40.126599Z

I quickly tried it under ./bb.edn

{:tasks {:init (defn foo! [& cmd-args]
                 (prn 42))}}
under bar/bb.edn
:deps {foo/foo {:local/root ".."}}
this didn't work in that as I run tasks under bar/, the foo! defn isn't available.

borkdude 2025-09-23T17:08:40.126559Z

:local/root must point at a deps.edn, not a bb.edn

borkdude 2025-09-23T17:08:50.244019Z

all deps related stuff goes through deps.edn

vemv 2025-09-23T17:10:08.091689Z

Hmm, okay. That might be slightly verbose but can try Should load-file work?

borkdude 2025-09-23T17:10:49.269869Z

yes, load-file also works. or you can dynamically add to the classpath with (babashka.classpath/add-classpath)

πŸ’― 1
richiardiandrea 2025-09-23T20:38:28.026909Z

Dear all - Ihave got an error on one of our internal machines - the error is pretty clear but I wonder if anybody has seen it and why it can happen...

'/root/.gitlibs/_repos/https/github.com/grzm/awyeah-api/info/exclude': File exists
Exception in thread "main" clojure.lang.ExceptionInfo:  babashka.process.Process@19010461
	at babashka.process$check.invokeStatic(process.cljc:111)
	at babashka.process$shell.invokeStatic(process.cljc:677)
	at babashka.impl.deps$add_deps$fn__28261.invoke(deps.clj:107)
	at borkdude.deps$_main.invokeStatic(deps.clj:1071)
	at borkdude.deps$_main.doInvoke(deps.clj:901)
	at clojure.lang.RestFn.applyTo(RestFn.java:140)
	at clojure.core$apply.invokeStatic(core.clj:667)
What this script does that is somewhat unique is that I am using (deps/add-deps (select-keys bb-edn [:deps :paths])) to add the deps from a bb.edn dynamically

borkdude 2025-09-24T08:27:13.439109Z

I have a kind-of repro here but I'm not sure if it's the same error you're facing.

(def fut1 (future (babashka.deps/add-deps '{:deps {com.grzm/awyeah-api {:git/sha "e5513349a2fd8a980a62bbe0d45a0d55bfcea141"
                                                                        :git/url ""}}})))

(def fut2 (future (babashka.deps/add-deps '{:deps {com.grzm/awyeah-api {:git/sha "9257dc0159640e46803d69210cae838d411f1789"
                                                                        :git/url ""}}})))

[@fut1 @fut2]
Run this script with:
rm -rf /tmp/g1 && GITLIBS=/tmp/g1 bb /tmp/foo.clj
and you'll see something like:
$ rm -rf /tmp/g1 && GITLIBS=/tmp/g1 bb /tmp/foo.clj
Cloning: 
Cloning: 
Error building classpath. Unable to clone  to /private/tmp/g1/_repos/https/github.com/grzm/awyeah-api:
fatal: destination path '/private/tmp/g1/_repos/https/github.com/grzm/awyeah-api' already exists and is not an empty directory.
Checking out:  at e5513349a2fd8a980a62bbe0d45a0d55bfcea141

borkdude 2025-09-24T08:40:45.510059Z

Same repro with JVM Clojure only:

(require '[clojure.repl.deps :as deps])

(def fut1 (future (deps/add-lib 'com.grzm/awyeah-api {:git/sha "e5513349a2fd8a980a62bbe0d45a0d55bfcea141"
                                                      :git/url ""})))

(def fut2 (future (deps/add-lib 'com.grzm/awyeah-api {:git/sha "9257dc0159640e46803d69210cae838d411f1789"
                                                      :git/url ""})))

[@fut1 @fut2]
$ rm -rf /tmp/g1 && GITLIBS=/tmp/g1 clj <<< '(load-file "/tmp/foo.clj")'
Clojure 1.12.2
user=> Execution error (ExceptionInfo) at clojure.tools.deps.interop/invoke-tool (interop.clj:81).
Unable to clone /private/tmp/g1/_repos/https/github.com/grzm/awyeah-api
fatal: destination path '/private/tmp/g1/_repos/https/github.com/grzm/awyeah-api' already exists and is not an empty directory.

richiardiandrea 2025-09-24T13:12:36.481029Z

the latest error seems the same but I am not doing anything in parallel here - as you can see I am only invoking the run.clj command - I suspect the parallel call happens internally to bb Could that be the case?

borkdude 2025-09-24T13:14:43.399919Z

going to try your repro

borkdude 2025-09-24T13:15:53.187829Z

$ rm -rf /tmp/g1 && GITLIBS=/tmp/g1 bb subdir/another-dir/run.clj
Cloning: 
Checking out:  at e5513349a2fd8a980a62bbe0d45a0d55bfcea141
Downloading: com/cognitect/aws/api/0.8.762/api-0.8.762.pom from central
Downloading: com/cognitect/aws/s3/871.2.32.2/s3-871.2.32.2.pom from central
Downloading: com/cognitect/aws/endpoints/871.2.32.30/endpoints-871.2.32.30.pom from central
Downloading: tolitius/inquery/0.1.22/inquery-0.1.22.pom from clojars
Downloading: tick/tick/1.0/tick-1.0.pom from clojars
Downloading: fipp/fipp/0.6.29/fipp-0.6.29.pom from clojars
Downloading: tolitius/yang/0.1.50/yang-0.1.50.pom from clojars
Checking out:  at 9257dc0159640e46803d69210cae838d411f1789
Downloading: com/cognitect/aws/api/0.8.762/api-0.8.762.jar from central
Downloading: com/cognitect/aws/endpoints/871.2.32.30/endpoints-871.2.32.30.jar from central
Downloading: com/cognitect/aws/s3/871.2.32.2/s3-871.2.32.2.jar from central
Downloading: fipp/fipp/0.6.29/fipp-0.6.29.jar from clojars
Downloading: tolitius/inquery/0.1.22/inquery-0.1.22.jar from clojars
Downloading: tick/tick/1.0/tick-1.0.jar from clojars
Downloading: tolitius/yang/0.1.50/yang-0.1.50.jar from clojars
Downloading pod org.babashka/postgresql (0.1.0)
Successfully installed pod org.babashka/postgresql (0.1.0)
---
/private/tmp/babashka-deps-repro/lib/lib-a
BEFORE add-dependencies
ℹ️ Available command ℹ️

borkdude 2025-09-24T13:16:33.738369Z

$ rm -rf /tmp/g1 && GITLIBS=/tmp/g1 bb subdir/another-dir/run.clj
Cloning: 
Checking out:  at e5513349a2fd8a980a62bbe0d45a0d55bfcea141
Checking out:  at 9257dc0159640e46803d69210cae838d411f1789
---
/private/tmp/babashka-deps-repro/lib/lib-a
BEFORE add-dependencies
ℹ️ Available command ℹ️

borkdude 2025-09-24T13:17:00.101329Z

repeating this a few times gives the same results and no, bb doesn't fetch any deps in parallel

borkdude 2025-09-24T13:17:12.448799Z

unless you do it yourself in a thread

borkdude 2025-09-24T13:18:09.053159Z

can you repro it locally?

borkdude 2025-09-24T13:52:12.807869Z

@richiardiandrea could it be that you are referring to awyeah-api with two different libnames (the key in :deps)?

borkdude 2025-09-24T13:53:33.076329Z

something like this:

(require '[babashka.deps :as deps])

(deps/add-deps '{:deps {com.grzm/awyeah-api-1 {:git/sha "e5513349a2fd8a980a62bbe0d45a0d55bfcea141"
                                               :git/url ""}
                        com.grzm/awyeah-api-2 {:git/sha "9257dc0159640e46803d69210cae838d411f1789"
                                               :git/url ""}}})

richiardiandrea 2025-09-24T16:10:37.104539Z

checking

richiardiandrea 2025-09-24T16:11:16.177209Z

I can repro locally but only in my other repo - not in the one I sent you

richiardiandrea 2025-09-24T16:13:03.750339Z

check and the dep name was the same - I had :git/tag in there as well

borkdude 2025-09-24T16:14:11.279219Z

perhaps you can make the repro more like your own repo?

richiardiandrea 2025-09-24T16:14:26.378629Z

yeah that's what I tried in the repo πŸ˜„

richiardiandrea 2025-09-24T16:14:38.698779Z

the dir structure is exactly the same

richiardiandrea 2025-09-24T16:15:04.635909Z

probably there is still something missing though - I am sure that if I find what triggers it we'll find the problem

richiardiandrea 2025-09-24T16:15:27.021149Z

for what is worth I am using v1.12.207

borkdude 2025-09-24T16:21:05.659799Z

208 is out btw

❀️ 1
richiardiandrea 2025-09-24T16:25:10.106149Z

I even removed the bb.edn from lib-b as per my project but that did not make any difference

richiardiandrea 2025-09-24T16:25:32.537659Z

in my project I see two concurrent Cloning...

richiardiandrea 2025-09-24T16:26:25.570239Z

wondering if bb is finding another bb.edn somewhere on the paths and launching itself twice but this is a wild wild guess

richiardiandrea 2025-09-24T16:29:50.522019Z

@borkdude I bumped to 208 and the problem went away!

Clojure tools not yet in expected location: /Users/.../.deps.clj/1.12.2.1565/ClojureTools/clojure-tools-1.12.2.1565.jar
Downloading  to /Users/.../.deps.clj/1.12.2.1565/ClojureTools/clojure-tools.zip
Unzipping /Users/.../.deps.clj/1.12.2.1565/ClojureTools/clojure-tools.zip ...
Successfully installed clojure tools!
Cloning: 
Downloading: org/clojure/clojure/1.12.2/clojure-1.12.2.pom from central
Checking out:  at e5513349a2fd8a980a62bbe0d45a0d55bfcea141
Checking out:  at 9257dc0159640e46803d69210cae838d411f1789
Downloading: org/clojure/clojure/1.12.2/clojure-1.12.2.jar from central
Not seeing two Cloning anymore

borkdude 2025-09-24T16:32:28.608689Z

ww nice!

richiardiandrea 2025-09-24T16:33:47.386919Z

Now I am curious to see the release notes πŸ˜„

borkdude 2025-09-24T16:35:49.274769Z

perhaps a change in tools.deps / deps.clj

πŸ‘ 1
borkdude 2025-09-24T16:35:58.064539Z

probably best to go through the commits between 207 and 208

borkdude 2025-09-24T17:42:39.477729Z

@richiardiandrea We can try this:

DEPS_CLJ_TOOLS_VERSION=1.12.1.1550 bb ..
DEPS_CLJ_TOOLS_VERSION=1.12.1.1561 bb ...
Also try with 1.12.2.1565 and 1.12.2.1571

borkdude 2025-09-24T17:43:12.256049Z

in 208 the default version is 1.12.2.1565

borkdude 2025-09-23T20:42:42.561979Z

hmm

borkdude 2025-09-23T20:43:12.041579Z

have you perhaps messed with .gitlibs manually?

richiardiandrea 2025-09-23T20:43:38.814429Z

hmm no this is a machine I don't have control over and does not happen locally

richiardiandrea 2025-09-23T20:44:27.038619Z

ok I deleted my local gitlibs and now I see the error

richiardiandrea 2025-09-23T20:44:54.073239Z

wait - maybe it's on my side

richiardiandrea 2025-09-23T20:45:06.134959Z

I see it is trying to clone twice

borkdude 2025-09-23T20:45:33.652229Z

my guess would be that tools.deps is trying to clone a git lib where the dir already exists or so

richiardiandrea 2025-09-23T20:46:27.816149Z

it might be the case that bb itself is download because it see it in bb.edn - then I add another one with deps/add-deps

richiardiandrea 2025-09-23T20:47:06.469969Z

but something is definitely going on

Cloning: 
Checking out:  at e5513349a2fd8a980a62bbe0d45a0d55bfcea141
Checking out:  at 9257dc0159640e46803d69210cae838d411f1789

richiardiandrea 2025-09-23T20:47:24.064749Z

and it happens before the call to deps/add-deps

borkdude 2025-09-23T20:48:08.047359Z

can you reproduce it?

richiardiandrea 2025-09-23T20:48:36.293299Z

trying

richiardiandrea 2025-09-23T21:06:57.398329Z

yeah so this happens when a library includes the same dependency with a different git/sha

richiardiandrea 2025-09-23T21:07:26.968209Z

I can push a repro in a second but I probably should match the git/sha πŸ˜„

borkdude 2025-09-23T21:09:53.122869Z

interesting :)

richiardiandrea 2025-09-23T21:10:30.619399Z

this is my mess - but because it's interesting I am about to send you a repo πŸ˜„

borkdude 2025-09-23T21:10:55.665509Z

normally tools.deps compares git/sha and selects the newest I believe, so yes, repro more than welcome

richiardiandrea 2025-09-23T21:11:02.921839Z

πŸ˜„

richiardiandrea 2025-09-23T21:11:29.539799Z

I am using :local/root for libs - that's maybe why

borkdude 2025-09-23T21:12:13.187369Z

could also be something suboptimal with babashka.add-deps, which doesn't care what's already on the classpath, it just adds more stuff to it

richiardiandrea 2025-09-23T21:18:47.884909Z

hmm strange - cannot reproduce anymore 😞

richiardiandrea 2025-09-23T21:46:22.594689Z

when I can repro I see two

Cloning: 
Cloning: 
other wise I see only one

richiardiandrea 2025-09-23T22:15:30.933389Z

sorry I could not make a repro with this - it seems finicky and might depend on my repo dir structure...

richiardiandrea 2025-09-23T22:52:09.832469Z

I'll leave the repo here though. in case you want to try https://github.com/arichiardi/babashka-deps-repro

richiardiandrea 2025-09-23T22:52:32.266689Z

will try more tomorrow and please let me know if you want me to try a bb with more logging.

borkdude 2025-09-24T06:32:11.698179Z

Could it be that you are using parallel babashka tasks? Perhaps tools deps isn’t prepared for concurrent downloads