rewrite-clj

2022-02-03T12:45:31.633779Z

Morning folks, my lovely tree-transformer from a couple of weeks ago (which is really just a thin wrapper around clj-rewrite’s walker) works fine when I run using “lein run”. However, our app is deployed via this jlib plugin that builds layered images rather stuffing the uberjar onto an image and running it. (new to me but seems intended to build more efficient images). Anyway, when I run the app via this image, I get the following error when invoking “ofString” to get the clj-zipper.

Argument of type: class rewrite_clj.reader.NewlineNormalizingReader cannot be converted to IPushbackReader
    at clojure.tools.reader.reader_types$eval439$fn__440.invoke(reader_types.clj:223)
	at clojure.tools.reader.reader_types$eval420$fn__421$G__411__428.invoke(reader_types.clj:215)
	at clojure.tools.reader.reader_types$indexing_push_back_reader.invokeStatic(reader_types.clj:379)
	at clojure.tools.reader.reader_types$indexing_push_back_reader.invoke(reader_types.clj:371)
	at clojure.tools.reader.reader_types$indexing_push_back_reader.invokeStatic(reader_types.clj:376)
	at clojure.tools.reader.reader_types$indexing_push_back_reader.invoke(reader_types.clj:371)
	at clojure.tools.reader.reader_types$indexing_push_back_reader.invokeStatic(reader_types.clj:374)
	at clojure.tools.reader.reader_types$indexing_push_back_reader.invoke(reader_types.clj:371)
	at rewrite_clj.reader$string_reader.invokeStatic(reader.cljc:264)
	at rewrite_clj.reader$string_reader.invoke(reader.cljc:261)
	at rewrite_clj.parser$parse_string_all.invokeStatic(parser.cljc:42)
	at rewrite_clj.parser$parse_string_all.invoke(parser.cljc:39)
	at rewrite_clj.zip.base$of_string.invokeStatic(base.cljc:93)
	at rewrite_clj.zip.base$of_string.invoke(base.cljc:85)
	at rewrite_clj.zip.base$of_string.invokeStatic(base.cljc:91)
	at rewrite_clj.zip.base$of_string.invoke(base.cljc:85)
	at rewrite_clj.zip$of_string.invokeStatic(zip.cljc:264)
	at rewrite_clj.zip$of_string.invoke(zip.cljc:258)
Anyone have any clues as to how I might fix this?

wilkerlucio 2022-03-31T18:42:55.680229Z

hello folks, I'm having a similar issue to this one, but in my case is while trying to use cljstyle (which uses rewrite-clj under the hood), I saw @cddr you said something about conflicting dependencies, but in my case the cljstye is everything I put, I'm running with this: clojure -Sdeps "{:deps {mvxcvi/cljstyle {:mvn/version \"0.15.0\"}}}" -m cljstyle.main check src test

wilkerlucio 2022-03-31T18:43:19.723249Z

I'm pretty sure this command used to work in the past, but for some reason now I get:

java.lang.IllegalArgumentException: Argument of type: class rewrite_clj.reader.NewlineNormalizingReader cannot be converted to IPushbackReaderError while processing file src/dev/dev_extras.clj
java.lang.IllegalArgumentException: Argument of type: class rewrite_clj.reader.NewlineNormalizingReader cannot be converted to IPushbackReaderError while processing file test/integration/member_flow.clj
java.lang.IllegalArgumentException: Argument of type: class rewrite_clj.reader.NewlineNormalizingReader cannot be converted to IPushbackReaderError while processing file test/integration/health_check_flow.clj
...

wilkerlucio 2022-03-31T18:56:03.752079Z

checking the deps tree, it seems to be using the correct version of org.clojure/tools.reader 1.3.6

2022-03-31T19:15:46.228239Z

This was the ultimate thing that fixed our problem https://clojurians.slack.com/archives/CHB5Q2XUJ/p1644503442071609

wilkerlucio 2022-03-31T19:24:57.699399Z

thanks man, I considered that, but in my case there is no clojurescript in the game, wonder if there are any other ideas out there

lread 2022-03-31T21:03:56.210719Z

@wilkerlucio if you try from the same dir:

clojure -Sdeps "{:deps {mvxcvi/cljstyle {:mvn/version \"0.15.0\"}}}" -Stree
You might maybe see another older version of rewrite-clj/rewrite-cljs? (`-Sdeps` are merged after your project deps)

wilkerlucio 2022-03-31T21:08:16.392019Z

humm, good point, I tough -Sdeps would replace the deps completely

wilkerlucio 2022-03-31T21:08:26.204029Z

using an alias with :replace-deps I got it to work fine

wilkerlucio 2022-03-31T21:08:40.315379Z

do you know if there is a way to replace strait from teh command line (so I wouldn't need the alias)?

lread 2022-03-31T21:09:58.967259Z

Hmmm… dunno. Without thinking about it too much… would a :replace-deps not work from the cmd line?

wilkerlucio 2022-03-31T21:10:26.110809Z

if that count as an alias, maybe, let me try 🙂

lread 2022-03-31T21:10:38.251329Z

If cljstyle installs as a clojure tool that might be another route.

wilkerlucio 2022-03-31T21:17:56.648169Z

found a thing that works, ugly, but works 😛 clojure -Sdeps "{:aliases {:cljstyle {:replace-deps {mvxcvi/cljstyle {:mvn/version \"0.15.0\"}}}}}" -M:cljstyle -m cljstyle.main check src test

lread 2022-03-31T21:24:13.239709Z

Oh right, of course… :replace-deps only works in aliases!

borkdude 2022-02-03T12:53:57.315529Z

Can you make a repro + issue?

lread 2022-02-03T13:09:34.680509Z

That's a new one to me as well @cddr looking forward to learning more.

slimslenderslacks 2022-02-03T22:07:45.182189Z

@cddr I can also help if this turns out to be a classloader problem resulting from the how the image was constructed. The set of jars on your classpath should be pretty close to what you get from lein run but I guess you're also maintaining a deps.edn too right?