kkinnear / zprint

Executables, uberjar, and library to beautifully format Clojure and Clojurescript source code and s-expressions.
MIT License
554 stars 47 forks source link

Version `1.2.4` with Babashka throws an exception #253

Closed rads closed 1 year ago

rads commented 2 years ago
$ BABASHKA_PRELOADS="" bb --config <(echo "{:deps {zprint/zprint {:mvn/version \"1.2.3\"} org.babashka/spec.alpha {:git/url \"https://github.com/babashka/spec.alpha\" :git/sha \"8df0712896f596680da7a32ae44bb000b7e45e68\"}}}") -e "(require '[zprint.core :as z]) (z/czprint {:a 1})"
{:a 1}

$ BABASHKA_PRELOADS="" bb --config <(echo "{:deps {zprint/zprint {:mvn/version \"1.2.4\"} org.babashka/spec.alpha {:git/url \"https://github.com/babashka/spec.alpha\" :git/sha \"8df0712896f596680da7a32ae44bb000b7e45e68\"}}}") -e "(require '[zprint.core :as z]) (z/czprint {:a 1})"
----- Error --------------------------------------------------------------------
Type:     java.lang.Exception
Message:  of-node* does not exist
Location: zprint/zutil.cljc:3:3

----- Context ------------------------------------------------------------------
1: ;!zprint {:style :require-justify}
2: (ns ^:no-doc zprint.zutil
3:   (:require
     ^--- of-node* does not exist
4:     #?@(:bb []
5:         :clj [[zprint.macros :refer [do-redef-vars]]])
6:     clojure.string
7:     zprint.zfns
8:     #?@(:clj [[zprint.redef]])

----- Stack trace --------------------------------------------------------------
zprint.zutil   - zprint/zutil.cljc:3:3
zprint.rewrite - zprint/rewrite.cljc:2:3
zprint.config  - zprint/config.cljc:7:3
zprint.zprint  - zprint/zprint.cljc:6:3
zprint.core    - zprint/core.cljc:5:3
user           - <expr>:1:1
kkinnear commented 2 years ago

Yes, this is because zprint 1.2.4 upgraded its dependency on rewrite-clj, and since rewrite-clj deprecated edn*, zprint started using of-node*. But babashka hadn't updated to the new version of rewrite-clj, and which version zprint was using ended up being the built-in version of rewrite-clj in babashka. I asked how to solve this over at babashka, and the suggestion was to use a pre-release of babashka from here

When I used a binary from this release: v0.9.162-SNAPSHOT it all worked for me.

I'm sorry that you need use a pre-release of babashka to fix this problem -- I spent a good while trying to figure out how to exclude rewrite-clj from babashka, with no success. I'm also sorry that I didn't test 1.2.4 better, as I have a test for babashka which I neglected to run. I'll ensure that I don't do that again.

Thanks for bringing this up!

rads commented 2 years ago

All good, just wanted to document it in case others were wondering in the mean time. Thanks for this awesome library!

kkinnear commented 1 year ago

The current babashka is babashka v1.0.169, which works fine with zprint.