Fork me on GitHub

wondering if writing nrepl-port file under say .bb/ or . nbb/ for nbb, would be a thing, to avoid clobbering jvm/clojure nrepl server written port file, kinda like .shadow-cljs/nrepl-port etc.


This could work if Calva and CIDER would support this. @U0ETXRFEW @U051BLM8F


Currently Calva by default will look for the files in the project root, as [".bb-nrepl.port"] and [".nbb-nrepl.port"] . I am totally ready to change the defaults to harmonize/standardize. The user also can create a Custom REPL connect sequence and specify the port file there. in case they don’t fancy whatever defaults we go with.


I didn't even know this


is this some kind of standard?


What would be a standard?


dunno, but what use is it to attempt read this file if the tool doesn't know it should produce this file :)

😄 2

but it's good that Calva has something for this. now it's just a matter of coming up with the right dir + name


and then we could change the Calva default


I'm inclined to something like .babashka/.nrepl-port


and .nbb/.nrepl-port


<dot-toolname/.nrepl-port> basically


the default file name for lein repl is:

user=> (slurp ".nrepl-port")


Yeah, so before you didn’t like the idea of bb creating this file. So then the user (or Calva) would need to do it. You gave me a nice snippet of code:

(import [ ServerSocket]
        [java.lang ProcessBuilder$Redirect])
(require '[babashka.wait :as wait])
(let [nrepl-port (with-open [sock (ServerSocket. 0)] (.getLocalPort sock))
      pb (doto (ProcessBuilder. ["bb" "--nrepl-server" (str nrepl-port)])
           (.redirectOutput ProcessBuilder$Redirect/INHERIT))
      proc (.start pb)]
  (wait/wait-for-port "localhost" nrepl-port)
  (spit ".nrepl-port" nrepl-port)
  (println "Press enter to kill the nREPL server.")
  (.destroy proc))
I adapted that some (can’t find it now, but anyway) and planned for Calva to help with both creating the file and looking for it at connect time. Then I decided to make Calva Jack-in watch stdout instead for when bb writes the port it uses there… Yeah, not sure I am making sense, but there it is. 😃


Well, I do like the convenience, but I don't like bb overwriting the clj REPL's file


so stuffing that in another dir would be a OK solution I guess


I'll make an issue for this


I hope to be able to support babashka’s and nbb’s REPLs while connected to clj or lein REPLs some day, so I totally agree about not overwriting the file.


One major issue: should the directory be .bb or .babashka :-s


In the beginning of bb I was overthinking this, considering the situation that there can also be multiple nREPL servers for the same tool


but perhaps this is not so important


I'll go with .bb since there is also bb.edn


Or what about bb , then we can also put scripts in there and it could be on the classpath by default


Both lein and clojure get by with using just one file for this, but babashka and nbb are different animals of course.


bb sounds good to me. Especially if it’s on the default classpath! Sounds lovely.


cool. perhaps bb.edn could also live inside of that directory then


not sure about that one


Totally recognize the threshing. 😃.


bb.edn bb/script.clj bb/.nrepl-port yeah I can live with this


We all can! ❤️


looking back after 13 hours at replies to a spontaneous idea, nice :D

😂 1

Being highly receptive to spontaneous ideas, his own and other's, is part of what explains the @U04V15CAJ phenomenon, I think.

❤️ 1

well said 🙂


Wondering babashka scripts would use .bb suffix and be stored in src , but maybe a bad idea 🙂 (just realised that I've been using .bb suffix for maybe no reason :D)


That’s also a option. This is already supported btw on the classpath, .bb has priority.


ahh nice, didn't know :)


Trying out a "pure" bb project (just bb.edn, no deps.ednso far) with calva. Calva testing support does not work at all for me. What would be the trick to get a smoother test experience? Introducing deps.edn ?


Not sure about #calva, perhaps @U0ETXRFEW has an idea here?


Do you mean Calva’s test runner commands, @U06FLL69W? They rely on cider-nrepl, so unless babashka has a shim for that, it won’t work. What you can do is create some custom commands/snippets that run the tests for you. See for how those works. And please reach out if you need help with it. When connected to babashka the repl session clj is used.

👍 1

I usually call (clojure.test/run-tests 'namespace) or just the test as a function

👍 1

Yes, so on that page there is an example snippet conf for the latter:

            "name": "CLJ Test Top Level Defined Symbol",
            "repl": "clj",
            "snippet": "(clojure.test/test-var #'$top-level-defined-symbol)"

👍 1

And something like this would run namespace tests and bind it to the keyboard shortcut ctrl+alt+space n

            "name": "Run namespace testsl",
            "repl": "clj",
            "snippet": "(clojure.test/run-tests '$ns)",
            "key": "n",


This feature request is somewhat related too, I think:


Guys, you are amazing!

❤️ 1

One more: I want to ship an oci image with an uberscript. Building this thing requires a jvm and bb. Is there a publically avaiable bb builder image or efforts on the way to provide one?


Not aware of one


@U06FLL69W Could you elaborate a bit more on builder image? you want to build an uberscript and have another image as a multistage? So the final image needs jvm and bb in it?


I think he means that the builder image needs a jvm (to resolve dependencies) but the final one doesn't

👍 1

got it. yeah we dont have one that has both now. probably a clojure/jdk image + installing bb could be the easiest


This is what I am doing. However, most java/clojure images had issues and it took a while to find one that works for this usecase. If we want this, I'd volunteer to build such a thing. However, I think is should live under the babashka umbrella at github.


@U06FLL69W Yes, I can give you a repo to work on if you want


Just let me know the name of the repo and your github id


@U04V15CAJ can we do it as adding a PR to the circleci setup that we have?


What does this have to do with a CircleCI setup?


as far as i understand we just need to build a docker image with the jvm and install bb in it right? can be done as another pipeline step?


build and push it


yes that would work


ok, @U06FLL69W perhaps you can share your Docker image and we can make something similar to that and push it to Dockerhub


and provide some docs around it


I can also start this thing under my deasgh account. However, it would be helpful to understand its final home context. Such as ci.


ok, start under deas and then we will take the next step from there

👍 1

@U06FLL69W I think the Clojure docker images could be a good place for this, too. Issue:

👍 1

There are a lot of clojure/java images. Most I tried had "issues" out of the box. I was aiming at minimalism. Currently ended up with:

# Most other images are missing git, curl or whatnot
FROM openjdk:11 as build
COPY . /build
WORKDIR /build
RUN curl -s  -o install && \
    chmod 755 install && \
    ./install && \
    ./test-runner.clj && \
    bb uberscript foo.clj -f src/foo.clj

FROM babashka/babashka:latest
# COPY --from=build ...


the one above is the one & only clojure image

Michael W23:10:20

I got holy-lambda babashka runtime working with the aws pod to do some nifty stuff today. I really like babashka.

👍 3
Karol Wójcik06:10:06

Babashka runtime soon will land a support for arm64. Which means even lower cold start and better performance.

Karol Wójcik11:10:14

What challenges have you come across when using holy-lambda? @UAB2NMK25

Michael W13:10:31

I think the hardest thing was figuring out how to look at the event and ctx objects to see how I could use it. You might want to document the keys/values for both event and ctx to make it easier for someone to get started. I used an api gateway and (hr/json) to "export" the objects to inspect them.

Michael W13:10:55

Once I knew what was available in those, it was smooth sailing, and it's really a great framework for getting something going fast. I replaced a python lambda that was taking 500ms per run with bb that is under 100ms per run doing the same thing.

Karol Wójcik14:10:02

Oh! Thanks for sharing. It would be probably easier to inspect the event shape using sam invoke. If you were following the tutorial this is a way to know the shape of the object. You can also check generate-event command :D Anyway, it's hard to document every single event option since HL does not transform the event much. Thanks for your thoughts.

Michael W14:10:59

I used sam local at the beginning, but because I was using aws apis and needed a valid keyid/secret I had to do my looking from the live lambda up in aws.

Michael W14:10:24

Even just a few pointers in the docs about how to get vars from the url would have saved me a bunch of time. I got past it doing (hr/json {:event event}) and using my browser to explore the json output with formatters.

Michael W15:10:44

I like holy-lambda quite a bit, it's brilliant!


@UAB2NMK25 I'm trying to do something similar. do you have a link to your code?

Karol Wójcik05:10:07

@U06FS3DLH have you tried following HL tutorial?