Fork me on GitHub
#shadow-cljs
<
2023-08-05
>
pez12:08:29

I need some help with ideas around why Calva’s node-library fails to compile when I try to use a cljfmt version later than 0.9.2. More details in 🧵

pez12:08:52

The error (I truncated the very long stack-trace):

❯ npx shadow-cljs compile :calva-lib      
shadow-cljs - config: /Users/pez/Projects/calva/shadow-cljs.edn
shadow-cljs - starting via "clojure"
[:calva-lib] Compiling ...
------ ERROR -------------------------------------------------------------------
 File: jar:file:/Users/pez/.m2/repository/dev/weavejester/cljfmt/0.11.2/cljfmt-0.11.2.jar!/cljfmt/core.cljc
failed to require macro-ns "cljfmt.core", it was required by "cljfmt.core"
Error in phase :compile-syntax-check
RuntimeException: No such var: z/of-node
        clojure.lang.Util.runtimeException (Util.java:221)
It seems to be something specific we do in Calva, because I fail to reproduce it in a minimal project. • Repoduction-attempt: https://github.com/PEZ/cljs-node-script • Calva shadow-cljs.edn: https://github.com/BetterThanTomorrow/calva/blob/dev/shadow-cljs.edn

thheller12:08:44

maybe an incompatible rewrite-clj version?

pez12:08:27

Ah, let me try that.

pez12:08:04

Ummm, realizing I don’t know how to try that. Thought it might be zprint bringing in something, but adding that to the dependency of the repro-attempt didn’t provoke the error…

thheller12:08:11

this is also a clojure error, so you can probably reproduce it via clj -A:whatever:aliases

thheller12:08:18

and then (require 'cljfmt.core)

thheller12:08:31

just look at clj -Stree and check which version you get

thheller12:08:51

the repro gets the correct one but your project may not?

pez12:08:19

Is it under the cljfmt node I should check? The repro:

dev.weavejester/cljfmt 0.11.2
  . org.clojure/tools.cli 1.0.219
  . org.clojure/tools.reader 1.3.6
  . com.googlecode.java-diff-utils/diffutils 1.3.0
  . rewrite-clj/rewrite-clj 1.1.47
Calva:
dev.weavejester/cljfmt 0.11.2
  . org.clojure/tools.cli 1.0.219 :newer-version
  . org.clojure/tools.reader 1.3.6
  . com.googlecode.java-diff-utils/diffutils 1.3.0
  . rewrite-clj/rewrite-clj 1.1.47

thheller12:08:43

run clj, activating whatever aliases that you need

thheller12:08:51

then (require '[ :as io])

thheller12:08:06

then (io/resource "rewrite_clj/zip.cljc")

thheller12:08:45

maybe thats pointing to a wrong file

pez12:08:29

Yeah:

❯ clj
Clojure 1.10.3
user=> (require '[ :as io])
nil
user=> (io/resource "rewrite_clj/zip.cljc")
#object[java.net.URL 0xaa5455e "jar:file:/Users/pez/.m2/repository/org/clojars/liverm0r/dartclojure/0.1.10-SNAPSHOT/dartclojure-0.1.10-SNAPSHOT.jar!/rewrite_clj/zip.cljc"]

thheller12:08:41

there you have your problem 😛

thheller12:08:53

looks like they bundle a dependency they shouldn't

pez12:08:02

Awesome, thanks Thomas!

pez12:08:57

@UL05W6AEM, I get this error also when using latest dartclojure (`0.2.15-SNAPSHOT`).

👀 1
Dumch14:08:04

I had

rewrite-clj/rewrite-clj {:mvn/version "1.0.767-alpha"}
Updated it to the latest 1.1.47. Published https://clojars.org/org.clojars.liverm0r/dartclojure/versions/0.2.16-SNAPSHOT

pez15:08:00

Thanks! It works, I get some warnings and will DM you about those. However, maybe this is the place for me to ask about wether this needs to be solved in a more permanent way? It seems like you suggest the bundling is avoidable, @U05224H0W?

thheller06:08:37

yes, you are not supposed to publish uberjars to clojars. you just publish your own sources and properly declare your dependencies.

thheller06:08:52

when you build uberjars they include every dependency you have. so when someone adds your library as a dependency they get everything you bundled, instead of what they may have declared. thus breaking the dependency resolution mechanism almost completely.

🙏 2
thheller06:08:03

leiningen handles this properly by default, don't know how to do it exactly in tools.build. maybe just b/jar instead of b/uber

✔️ 2