Fork me on GitHub
Ian Fernandez04:06:56

anyone having problems with clj-http lite?

Ian Fernandez04:06:14

I couldn't require the client ns

Ian Fernandez04:06:19

using babashka

Ian Fernandez16:06:54

deps.edn =>

:paths   ["src"]
 :deps    {medley                          {:mvn/version "1.3.0"}
           org.clojure/data.xml            {:mvn/version "0.0.8"}
           com.amazonaws/aws-java-sdk-s3   {:mvn/version "1.11.796"}
           org.martinklepsch/clj-http-lite {:mvn/version "0.4.3"}
           clj-http                        {:mvn/version "3.10.1"}
           ;;potemkin                        {:mvn/version "0.4.5"}
 :aliases {:test {:extra-paths ["test"]}}}

Ian Fernandez16:06:17

repl script =>

export BABASHKA_CLASSPATH=$(clojure -Spath)
#export BABASHKA_PRELOADS="(require '[new.namespace])"

bb --classpath src:test --nrepl-server 1666


@d.ian.b try setting your classpath


If you don’t want a library there’s also babashka.curl @d.ian.b

Ian Fernandez16:06:44

I want a library that I can use both in clj and bb


babashka.curl also works in clojure


but so does clj-http-lite.

Ian Fernandez16:06:58

I'll try to use babashka.fcurl in clj then

Ian Fernandez16:06:12

I'm trying to migrate ancient-clj to bb / clj


You can also use reader conditionals with :bb for babashka specific code

Ian Fernandez17:06:14

yup but It's not working on cider =(


what do you mean?


CIDER should support this, else it's a bug


Btw, I just tried from CIDER and it does seem to work?

Ian Fernandez20:06:53

I was saying about the less opaque part of the #?()

Ian Fernandez20:06:08

that bb has to be lighter than clj

Ian Fernandez20:06:28

but thanks 😃


Invoke vim in the middle of a script, discovered by @marques.goncalves.fel :

#!/usr/bin/env bb

(require '[ :as io])

(defn vim [file]
   (ProcessBuilder. ["vim" file])

(def readme
  (let [f (io/file "")]
    (when (not (.exists f))
      (vim (.getPath f)))
    (slurp f)))

(println readme)


I am publishing my very first Babashka pod that uses multigrep library.


@agilecreativity nice! any reason you're not just using it directly?

borkdude@MBP2019 ~ $ export BABASHKA_CLASSPATH=$(clojure -Sdeps '{:deps {clj-commons/multigrep {:mvn/version "0.5.0"}}}' -Spath)
borkdude@MBP2019 ~ $ rlwrap bb 
Babashka v0.1.1-SNAPSHOT REPL.
Use :repl/quit or :repl/exit to quit the REPL.
Clojure rocks, Bash reaches.

user=> (require '[multigrep.core :as mg])
user=> (first (mg/grep #"babashka" "/Users/borkdude/Dropbox/dev/clojure/babashka/"))
{:file "/Users/borkdude/Dropbox/dev/clojure/babashka/", :line "<img src=\"logo/babashka.svg\" width=\"425px\">", :regex #"babashka", :re-seq ("babashka"), :line-number 1}


Wow, forgot about -Spath , I want to added one more function to it to my use-case. e.g. greplace-all! in this case. And just want to learn how to leverage the pod system with it. I know it is very simple library (easy for me to start with). Thanks for creating Babashka and the pod system. It is really nice to be able to interact with many library via the cli.


qq: I am getting the error when I remove the following pr-str in the calling of the function. e.g.


Must i return string all the time for the main function to work?


e.g. if I remove the pr-str from the last line I am getting some errors:

(defn grep
  [pattern file]
  (-> (mgrep/grep (re-pattern pattern) file)


what is the error


Let me try to replicate it.


I'll be right back


Here is the errors:

#error {
 :cause "No dispatch macro for: \""
 [{:type java.lang.RuntimeException
   :message "No dispatch macro for: \""
   :at [clojure.lang.Util runtimeException "" 221]}]
 [[clojure.lang.Util runtimeException "" 221]
  [clojure.lang.EdnReader$DispatchReader invoke "" 552]
  [clojure.lang.EdnReader readDelimitedList "" 757]
  [clojure.lang.EdnReader$MapReader invoke "" 680]
  [clojure.lang.EdnReader readDelimitedList "" 757]
  [clojure.lang.EdnReader$ListReader invoke "" 654]
  [clojure.lang.EdnReader read "" 145]
  [clojure.lang.EdnReader read "" 111]
  [clojure.lang.EdnReader readString "" 67]
  [clojure.edn$read_string invokeStatic "edn.clj" 46]
  [babashka.pods.impl$processor$fn__15148 invoke "impl.clj" 82]
  [babashka.pods.impl$processor invokeStatic "impl.clj" 94]
  [babashka.pods.sci$fn__15240$fn__15273 invoke "sci.clj" 63]
  [sci.impl.vars$binding_conveyor_fn$fn__7581 invoke "vars.cljc" 142]
  [clojure.core$binding_conveyor_fn$fn__5758 invoke "core.clj" 2032]
  [clojure.lang.AFn call "" 18]
  [java.util.concurrent.FutureTask run "" 264]
  [java.util.concurrent.ThreadPoolExecutor runWorker "" 1128]
  [java.util.concurrent.ThreadPoolExecutor$Worker run "" 628]
  [java.lang.Thread run "" 834]
  [ threadStartRoutine "" 517]
  [ pthreadStartRoutine "" 193]]}


I push my changes to develop branch: The diff was:

(defn grep
   [pattern file]
   (-> (mgrep/grep (re-pattern pattern) file)
-      pr-str))
+      #_pr-str
+      identity
+      ))


It is failing around this call:

(mgrep/grep "defproject" "project.clj")


The code to replicate the issue is in smoke-test.clj in the root of the project:

#!/usr/bin/env bb
(require '[babashka.pods :as pods])
(pods/load-pod ["pod-b12n-mgrep"])
(require '[pod.b12n.mgrep :as mgrep])

 (mgrep/grep "defproject" "project.clj")

 (mgrep/grep "mvn" "deps.edn")


When run directly I am getting the correct result:

(grep "defproject" "project.clj")

({:file "project.clj", :line "(defproject net.b12n/pod-mgrep \"1.0.0\"", :line-number 1, :regex #"defproject", :re-seq ("defproject")})


your error seems to indicate you're trying to send a regex over the wire?

user=> (edn/read-string (pr-str #"foo"))
Execution error at user/eval5 (REPL:1).
No dispatch macro for: "


I see, I noticed that also that anything that is not string will not work. Right?


The protocol uses EDN or JSON. So arguments serialized as EDN should be also readable as EDN


Got it, so I can also send it using json by specify “format” “json” ?


You can also define "client side" functions to work around limitations.


Can you explain what is client side function?


E.g. you can define (defn foo [x] (if (regex? x) {:regex (str x)}) and then decode :regex as a regex in your pod.


Thank you. Now it all make sense to me.


I'm also using this in the sql pods to send connections between bb and the pod. connections are just represented as a map with an id in it


and I translate those maps back to a connection on the pod side

👍 4

one other tip if you weren't aware of it: you can test your pod with the pod library on the JVM before natively compiling it


this makes iterating on it faster


I see, so just add that as dependency and try to see if that work first.


I should do that going forward. Thanks for the tips


In the case of regex above, I guess I can also use reader to handle it

{"readers" {"my/tag" "clojure.core/identity"}}
like the example from the doc?


I totally forgot about that, but I guess so 🙂

David Pham18:06:42

Just my two 2 cents for improvement for babashka. This is only a personal feedback, so I hope you do not take it personally, it is probably only me. One of my biggest issue is about adding library to Babashka. I know there is documentation, but somehow, it does not feel easy (as you have to export the classpath as a string and everything, and it might be harder to make transportable). For example, I wanted to use clj-http-lite and I find it convoluted. Is there a way babashka could leverage on deps.edn for building the cp?


@neo2551 Btw, any reason you're using clj-http-lite and not the built-in babashka.curl? Maybe besides the point of using libs as a general question

David Pham19:06:00

I tried it at work, and I just wanted to make a post request with some arguments and somehow with a similar code clj-http-lite managed to return me the correct response while babashka.curl could not.

David Pham19:06:21

It was about content length from the header request

David Pham19:06:41

I was a bit in a rush, so I did not took the time to perfectly found the cause, sorry.


please report any issues with babashka.curl at

David Pham19:06:05

I would need to find the exact cause, otherwise I don't want to waste your time!


sure 🙂 so tl;dr: deps.clj is the answer I have to your question currently

David Pham19:06:31

I will try that 🙂 Thanks a lot

David Pham19:06:36

Does deps start faster than clojure?


similar. there are two flavors: one that runs as a babashka script and natively compiled binaries for linux, mac and windows.


the bb script runs a few ms slower than the bash equivalent, the binary might be slightly faster