Welcome! Please see the About page for a little more info on how this works.

+2 votes
in tools.build by

The conflict handler for data_readers.clj* treats the files as EDN when it reads them to merge them. This fails for .cljc files containing reader conditionals:

RuntimeException No dispatch macro for: ?
	clojure.lang.Util.runtimeException (Util.java:221)
	clojure.lang.EdnReader$DispatchReader.invoke (EdnReader.java:552)
	clojure.lang.EdnReader.readDelimitedList (EdnReader.java:757)
	clojure.lang.EdnReader$MapReader.invoke (EdnReader.java:680)
	clojure.lang.EdnReader.read (EdnReader.java:145)
	clojure.lang.EdnReader.read (EdnReader.java:111)
	clojure.lang.EdnReader.readString (EdnReader.java:67)
	clojure.edn/read-string (edn.clj:46)
	clojure.edn/read-string (edn.clj:37)
	clojure.edn/read-string (edn.clj:37)
	clojure.tools.build.tasks.uber/conflict-data-readers (uber.clj:89)
	clojure.tools.build.tasks.uber/conflict-data-readers (uber.clj:86)
tricky because it really should keep the conditionals in the output of the merge
Not actually that tricky as the reader has support for this with :read-cond :preserve
Thanks Sean for reporting this here after I mentioned it on slack

I've since realized that this seems to be occurring when I depend on both aws-api and tick, and only when I try to call the uber function from a repl. It to works when I use `clj -T:build build` from the command line.

Here's a minimal reproduction of the error
interesting how the current merge is implemented. The current repl-only issue aside, it work fine for data_readers.cljc with conditional content where only the values are conditional, such as:

{foo/bar #?(:clj xxx :cljs yyy)}

but wouldn't work for this (which is valid content):

#?(:clj {foo/bar clojure.core/identity})

I'm not saying the above is great style ofc.

I had assumed it would not preserve, but instead read the :clj branch. bc why would you want anything but :clj in your uberjar?
I figured out my issue here. Locally I was depending on the earlier version of tools.build in a dev alias, a version prior to 8.3 when this was fixed. I thought I was checking this by looking at the deps tree but I had confused myself at some point and convinced myself that I wasn't. Sorry for the confusion here

1 Answer