Fork me on GitHub
#portal
<
2024-03-11
>
Mateusz Mazurczak13:03:41

Portal fails when updated from 0.51.1 to 0.52.2 and run with babashka.

Type:     clojure.lang.ExceptionInfo
Message:  Could not resolve symbol: definterface
Data:     {:type :sci/error, :line 22, :column 1, :file "clojure/data/json.clj", :phase "analysis"}
Location: clojure/data/json.clj:22:1
Phase:    analysis
----- Context ------------------------------------------------------------------
18: ;; CUSTOM PUSHBACK READER
19:
20: (set! *warn-on-reflection* true)
21:
22: (definterface InternalPBR
    ^--- Could not resolve symbol: definterface
23:   (^int readChar [])
24:   (^long readChars [^chars buffer ^long start ^long bufflen])
25:   (^void unreadChar [^int c])
26:   (^void unreadChars [^chars buffer ^int off ^int bufflen])
27:   (^java.io.Reader toReader []))
It is exactly the same error that antq library fixed in https://github.com/liquidz/antq/blob/main/CHANGELOG.adoc#281185-2024-02-23

borkdude13:03:23

clojure.data.json no longer works with babashka, the newest version broke compatibility

borkdude13:03:00

a solution would be to use https://github.com/babashka/json which dispatches to whatever json library you uses and does the optimal thing for bb

djblue15:03:19

In Portal clojure.data.json is only referenced https://github.com/djblue/portal/blob/master/src/portal/runtime/json.cljc#L4. Which is under the more specific require for :bb which is cheshire.core. I do think I bumped the version of org.clojure/data.json from 2.4.0 to 2.5.0 when I upgraded all the dependencies in Portal, but I don't mind reverting it back if it's causing issues transitively.

borkdude16:03:14

Well, it is a sign that clojure.data.json is at least loaded in portal, you could make that :bb nil as well since loading dependencies that aren't really used only takes time

djblue16:03:12

(ns ^:no-doc portal.runtime.json
  (:refer-clojure :exclude [read])
  #?(:bb   (:require [cheshire.core :as json])
     :clj  (:require [clojure.data.json :as json])
     :cljr (:require [portal.runtime.clr.assembly]
                     [clojure.data.json :as json])))
Since :bb comes before :clj and reader conditionals are mutually exclusive, Portal shouldn't be loading clojure.data.json at all :thinking_face:

djblue16:03:17

I think the issues here is that Portal will break user code by forcing a later version of clojure.data.json transitively.

borkdude16:03:43

ok you think it was just @U0281QDFE1X himself who loaded clojure.data.json -- right, that makes sense

djblue16:03:51

Yeah, just confirmed that Portal will load in bb with 0.52.2 👌

djblue08:03:57

Fixed this with https://github.com/djblue/portal/commit/92c025852bd01016ac62a684bbf71f709592d92d which should now be released in 0.53.0 👌

🎉 2