Fork me on GitHub
#babashka
<
2022-07-22
>
jjttjj13:07:49

I'd like to enable clojure.core.reducers from babashka. My current understanding is that I'd have to do a custom build of babashka that includes the java.util.concurrent.ForkJoin* classes the reducers library uses (https://github.com/clojure/clojure/blob/master/src/clj/clojure/core/reducers.clj). Is there anything I'm missing? (This is because I'd like to use a library that depends on reducers: https://github.com/dco-dev/interval-tree)

borkdude13:07:36

Is clojure.core reducers crucial to that library? I only see one usage of it in core.clj - perhaps you can replace this usage with transducers in a reader conditional (or macro which dispatches on bb vs clj)

borkdude13:07:52

(defmacro if-bb [then else]
  (if (System/getProperty "babashka.version") then else))

jjttjj13:07:08

good point, that's probably the route I'll go down, thanks!

pinkfrog16:07:44

How does bb build classpath regarding

:deps {local/deps {:local/root "."}}
? Example to reproduce: 1. Create an empty bb.edn file, and add the following
{:paths ["./"]
 :deps {local/deps {:local/root "."}}}
Classpath is populated. (What’s the logic to add classpath?) Also, if I change the above to
{:paths ["./"]
 :deps {local/deps {:local/root "./"}}}
The bb errs with error building classpath.

borkdude16:07:33

local/root scans a directory for a deps.edn file and those deps are added to the classpath

borkdude16:07:01

I recommend using just "." and not "./"

Jeffrey Bay19:07:21

so in the dir specified by the :local/root you could put a deps.edn with it's own :dir pointed to, say, "." or whatever else you wanted "src" etc

Jeffrey Bay19:07:38

interesting. i was trying something related last week and didn't get how that worked

borkdude19:07:00

yes, you could

borkdude19:07:13

this is just a feature of the #tools-deps stuff

pinkfrog00:07:19

> so in the dir specified by the :local/root you could put a deps.edn with it’s own :dir pointed to, say, "." or whatever else you wanted "src" etc Are you saying the :paths instead of :dir ?

pinkfrog00:07:22

> I recommend using just "." and not "./" (edited) @U04V15CAJ I was saying 1. specifying “.”, and “./” have a different effect, though they shall be the same. 2. Further, even if there is no deps.edn under the current directory, specifying “.” still adds some deps. I am investigating where it comes from.

pinkfrog00:07:30

@U04V15CAJ A reproducible example on myside is:

mkdir test-bb; cd test-bb
echo "{:deps {local/deps {:local/root "."}}}" > bb.edn
bb
(require '[babashka.classpath :refer [get-classpath]])
(get-classpath)
A bunch of classpaths are showing up. user=> (get-classpath)
"/Users/pinkfrog/files/dev/mine/bb/src:/Users/pinkfrog/files/dev/mine/bb/resources:/Users/pinkfrog/files/dev/mine/clj/src:/Users/pinkfrog/files/dev/mine/clj/resources:/Users/pinkfrog/.gitlibs/libs/org.babashka/spec.alpha/1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78/src/main/java:/Users/pinkfrog/.gitlibs/libs/org.babashka/spec.alpha/1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78/src/main/clojure:/Users/pinkfrog/.gitlibs/libs/org.babashka/spec.alpha/1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78/src/main/resources:/Users/pinkfrog/.m2/repository/babashka/process/0.1.7/process-0.1.7.jar:/Users/pinkfrog/.m2/repository/cheshire,,,,
This one
/Users/pinkfrog/files/dev/mine/bb/src
Is one of my local repo. Dunno why it gets included.

pinkfrog01:07:09

@U04V15CAJ I removed the ~/.config/clojure/.cpcache, and the issue has now gone.

pinkfrog01:07:16

Not sure about the exact parts. But there must be some issue on the dependency caching. This answers my previous two questions.

pinkfrog01:07:56

It looks like the logic is, bb (or the deps tool) checks there is a key “.” in the cache, so it directly gives the classpath. It doesn’t even look if ./deps.edn exists or not, let alone the file’s cache.