This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2022-04-14
Channels
- # aleph (2)
- # announcements (11)
- # aws (4)
- # babashka (42)
- # babashka-sci-dev (81)
- # beginners (90)
- # biff (2)
- # calva (40)
- # cider (16)
- # clj-kondo (26)
- # clj-on-windows (1)
- # cljdoc (4)
- # cljfx (1)
- # cljsrn (2)
- # clojure (92)
- # clojure-austin (2)
- # clojure-europe (23)
- # clojure-nl (5)
- # clojure-uk (3)
- # clojured (3)
- # clojurescript (19)
- # community-development (3)
- # conjure (1)
- # cursive (4)
- # datalevin (3)
- # datomic (5)
- # emacs (13)
- # events (1)
- # fulcro (26)
- # graphql (1)
- # hugsql (15)
- # introduce-yourself (5)
- # leiningen (1)
- # lsp (29)
- # minecraft (19)
- # music (1)
- # off-topic (36)
- # pathom (12)
- # podcasts (2)
- # portal (8)
- # re-frame (12)
- # reagent (11)
- # rewrite-clj (4)
- # shadow-cljs (56)
- # spacemacs (2)
- # vim (12)
- # windows (3)
- # xtdb (43)
I have a bb script in a Clojure project. Is there a standard place to put it?
<myproject>/src/...
?
I'd like users to be able to use it from the command line. (The script sends messages to a running program, modifying the program's behavior).
In Cursive I cannot mark it as a bb script unless it is in the class path it seems. Will request that feature
Ah, does that :tasks
make it runnable as foo
from the command line? Will read the docs.
Hmm, I'd just like to run it as foo <cmd line opts>
. Perhaps I need to invoke the bb script from a shell script?
if you don't mind typing bb foo <cmd line opts>
then the above task usage does it
My preferred library for debugging is https://github.com/weavejester/hashp Is this something you'd consider adding to babashka?
It seems hashp is not going to work, since it seems to depend on deps that are not going to run with bb:
clojure.core.rrb-vector.nodes - clojure/core/rrb_vector/nodes.clj:11:3
clojure.core.rrb-vector - clojure/core/rrb_vector.clj:43:3
fipp.deque - fipp/deque.cljc:4:3
fipp.engine - fipp/engine.cljc:4:3
puget.printer - puget/printer.clj:94:3
it's probably not too hard to write a simplified bb-compatible version of this which just uses pprint
$ bb -e '(taoensso.timbre/spy 1)'
2022-04-14T09:50:06.718Z m1.local DEBUG [user:1] - 1 => 1
1
Can puget be required in a babashka script?
I expect it not to work since it depends on fipp and there's some things in fipp that don't work in bb (deftype), I think
I have a CLI version of puget here: https://github.com/borkdude/puget-cli
Actually I'm now looking into making fipp compatible with bb and it looks like that might actually work with some changes
Tweaking fipp + puget a bit and it seems they can be made to work from source (hopefully the authors will cooperate). More info here: https://github.com/babashka/babashka/issues/1241

Cool! I had tried and it did not work with a simple require. I should have written that!
Color can be so helpful when you have complex data to display
I guess it's way to special without a simple repro but
java.util.zip.ZipException: invalid entry CRC (expected 0xbe1ee0ab but got 0xc113eb74)
at java.util.zip.ZipInputStream.readEnd (ZipInputStream.java:410)
(defn
unzip
[zip-file destination]
(with-open
[xin
(io/input-stream zip-file)
^ZipInputStream zip (ZipInputStream. xin)]
(loop
[ze (.getNextEntry zip)]
(when
ze
(let [f (io/file
destination
(.getName ze))]
(io/make-parents f)
(io/copy zip f)
(.closeEntry zip)
(recur (.getNextEntry zip)))))))
any idea? for some reason it works on jvm. It also usually works, but I found a zip that throws. Can't really share the zip file that is causing it rn, it's sensitive, but I'll try to find a simple reproTweaking fipp + puget a bit and it seems they can be made to work from source (hopefully the authors will cooperate). More info here: https://github.com/babashka/babashka/issues/1241

Btw, zprint already works with bb:
(ns zprint
(:require [babashka.deps :as deps]))
(deps/add-deps '{:deps {org.babashka/spec.alpha {:git/url ""
:git/sha "1a841c4cc1d4f6dab7505a98ed2d532dd9d56b78"}
zprint/zprint {:mvn/version "1.2.3"}}})
(require '[zprint.core :as zp])
(println (zp/zprint-file-str (slurp *file*) "yolo" {:color? true :style :dark-color-map}))
FYI, it looks like this broke with 1.2.4
. Created an issue: https://github.com/kkinnear/zprint/issues/253