Fork me on GitHub
#babashka
<
2021-12-08
>
Gerome09:12:06

Good morning, I sometimes have this problem with my nrepl session where I execute a form and then it doesn't return. In this case it's (-> @(p/process ["git" "log" "--numstat" "--pretty=format:'[%h] %an %ad %s'" "--date=short"]) :out slurp), where p is babashka.process.

borkdude09:12:44

@gerome.bochmann Does that process have long output as in, pages long?

Gerome09:12:37

Yes, it's a long output

borkdude09:12:54

In this case it's better to use :out :string since the way you're doing it now it fills a buffer which is never consumed before the process ends and then the process is waiting.

borkdude09:12:56

(-> @(p/process ... {:out :string}) :out)

Gerome09:12:02

Ha! That helped! Thanks @borkdude

👍 1
André Peric Tavares14:12:18

Hi folks. I’m trying to use (binding [*default-data-reader-fn* tagged-literal] ...) , but I’m getting this error:

70: (binding [*default-data-reader-fn* tagged-literal]
              ^--- Could not resolve symbol: *default-data-reader-fn*
What would be the expected way of using tagged-literal for unknown tags?

André Peric Tavares14:12:39

Also tried to require [clojure.tools.reader.default-data-readers], seems that it’s not available

borkdude14:12:48

@andre.peric this is added in the newest bb: 0.6.8. are you using that?

André Peric Tavares14:12:27

I’m using v0.6.5. Will update, thanks 🚀

André Peric Tavares14:12:15

I’m getting this error. I though it was supposed to handle all unknown tags:

74: (binding [*default-data-reader-fn* tagged-literal]
75:   (main 1))
      ^--- No reader function for tag my/redacted-tag
I’m reading a file with edn/read-string in main. Maybe my expectations are wrong :thinking_face:

borkdude14:12:04

yeah, default-data-reader-fn only works for clojure.core/read. edn/read-string supports an options map:

borkdude14:12:30

clojure.edn/read
([] [stream] [opts stream])
  Reads the next object from stream, which must be an instance of
  java.io.PushbackReader or some derivee.  stream defaults to the
  current value of *in*.

  Reads data in the edn format (subset of Clojure data):
  

  opts is a map that can include the following keys:
  :eof - value to return on end-of-file. When not supplied, eof throws an exception.
  :readers  - a map of tag symbols to data-reader functions to be considered before default-data-readers.
              When not supplied, only the default-data-readers will be used.
  :default - A function of two args, that will, if present and no reader is found for a tag,
             be called with the tag and the value.

borkdude14:12:02

so you need to use (clojure.edn/read-string {:default (fn [tag value] ...)} ...)

André Peric Tavares14:12:46

Oh. Makes sense. Thanks a lot, @borkdude

borkdude23:12:48

Added a bunch of libs to CI for testing the new spec compatibility: • better-cond • coax (exoscale) • orchestra (also tests expound indirectly) • integrant • tested guardrails manually, but tests are hard to extract, they are intertwined with loading ClojureScript

👏 2
Mandimby Raveloarinjaka23:12:03

Does net.cgrand/xforms work with babashka? I thought I read that somewhere but I cannot see it in the list of projects (https://github.com/babashka/babashka/blob/master/doc/projects.md) and when I try to add it I get an error ; eval (current-form): (require '[net.cgrand.xforms :as x]) ; (err) : Unable to resolve classname: java.util.Comparator

borkdude07:12:24

Which version are you using? I have an open PR at xforms which should make it compatible with bb 068. Please leave some feedback at the PR to encourage the maintainer to merge it

Mandimby Raveloarinjaka16:12:33

I am using 0.6.1. Thanks for the answer I will check the PR.

borkdude16:12:20

I recommend using 0.7.0 and you can use my original fork meanwhile