Fork me on GitHub
#mranderson2023-01-02
lread20:01:32

Welcome to the MrAnderson channel, folks!

Mor Gazith20:01:58

continuing my thread from #C053AK3F9 https://clojurians.slack.com/archives/C053AK3F9/p1672663790253469

hey, i'm trying to use mranderson to shade my library's dependencies so they won't interfere with my other repos using this lib.
anyone here has any experience using it and can help out?

Mor Gazith20:01:40

ok, so i’m using the original repo https://github.com/fullcontact/full.aws on master. here are my steps and results so far: 1. Checkout orig repo full.aws 2. lein do clean, deps, test => 3. add mranderson 5.3.0 to plugins > lein do clean, deps, test => 4. add ^:inline-dep to all full.* deps and to jaxb-api > lein do clean, deps, test => 5. lein inline-deps > RuntimeException: No reader function for tag Inf => :face_palm: 6. change plugin version to [thomasa/mranderson "0.5.4-SNAPSHOT"] > lein inline-deps > so 0.5.3 seems broken, while 0.5.4-SNAPSHOT can run inline-deps, at least on my env.

Mor Gazith20:01:32

7. lein with-profile +plugin.mranderson/config test =>

Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:382).
fullaws100SNAPSHOT.fullaws100SNAPSHOT.fullaws100SNAPSHOT.clojure.lang.IRecord
this is the bug i wrote earlier, where it duplicates the prefix multiple times at many sources, like this:
(:import (fullaws100SNAPSHOT.fullaws100SNAPSHOT.fullaws100SNAPSHOT.clojure.lang IRecord IType IObj IReference Var)))

Mor Gazith20:01:35

8. search & replace: (fullaws100SNAPSHOT\.){2,} => fullaws100SNAPSHOT. the above import looks sane now, but still fails

Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:382).
fullaws100SNAPSHOT.clojure.lang.IRecord
looking at the source tree under target/srcdeps/fullaws100SNAPSHOT/clojure/lang i see only IBlockingDeref and IDeref, no sign of IRecord, IType, IObj, IReference or Var

Mor Gazith20:01:35

not sure how to move forward from here, i’m stuck

lread21:01:38

Nice summary @U04H5V7URR9! I'll start with reproducing your steps (probably) tomorrow, and then digging into what is going on.

Mor Gazith22:01:03

thank you 🙏

lread17:01:55

Ok starting to try things out. I think I'll verify 0.5.4-SNAPSHOT as other folks are using that in production.

lread17:01:30

I'm not sure that lein test has value? I don't see any tests for full.aws. Maybe it at least loads some nses? I dunno.

lread17:01:11

Oh ya, I guess that is its value, as I see you get a failure from launching tests.

Mor Gazith17:01:21

it'll output 0 tests which means it complied successfully

👍 2
lread17:01:44

@U04H5V7URR9 what JDK are you using? Probably should match that too.

Mor Gazith17:01:56

I think I'm running jdk8 for this one

lread17:01:24

Ok. Also can you paste your project.clj ? Just to be sure we are using same.

lread18:01:51

That's a lot of inline deps yeah? Takes a while!

Mor Gazith18:01:52

yep, tell me about it 🙂 took over 5 minutes

Mor Gazith18:01:28

maybe I'm using it wrong? my aim was to bump the aws SDK version without causing Jackson dependency hell

Mor Gazith18:01:48

which I had before hearing about mranderson

lread18:01:05

Hmm... yeah, are you actually suffering Jackson dependency hell or just trying to be proactive?

lread18:01:52

Also: I seem to be getting a different result than you:

❯ lein with-profile +plugin.mranderson/config test
Compiling full.aws.core
Syntax error macroexpanding at (core.clj:1:1).
Execution error (FileNotFoundException) at full.aws.core/loading (core.clj:1).
Could not locate full/core/config__init.class, full/core/config.clj or full/core/config.cljc on classpath.

Full report at:
/tmp/clojure-4717255487822232053.edn
Compilation failed: Subprocess failed (exit code: 1)
Error encountered performing task 'test' with profile(s): 'base,system,user,provided,dev,config'
Compilation failed: Subprocess failed (exit code: 1)

Mor Gazith18:01:32

I am suffering hell, for over a week before going with the shading approach

👍 2
Mor Gazith18:01:00

I never got that FileNotFound issue

lread18:01:27

Can you paste the project.clj you tested with above?

Mor Gazith18:01:21

for the sake of minimizing the moving parts here, let me try with inlining just one dep

lread18:01:45

ya that's what I'm trying

lread18:01:09

just trying full.json because it seems to dep on jackson

Mor Gazith18:01:10

which one did you choose?

lread18:01:19

Seems to be closer to what you were reporting:

❯ lein with-profile +plugin.mranderson/config test
Compiling full.aws.core
Compiling full.aws.dynamo.kvstore
Compiling full.aws.s3
Compiling full.aws.sqs
Compiling mrandersonf3f583ec.camel-snake-kebab.v0v4v0.camel-snake-kebab.core
Compiling mrandersonf3f583ec.camel-snake-kebab.v0v4v0.camel-snake-kebab.extras
Compiling mrandersonf3f583ec.camel-snake-kebab.v0v4v0.camel-snake-kebab.internals.alter-name
Compiling mrandersonf3f583ec.camel-snake-kebab.v0v4v0.camel-snake-kebab.internals.macros
Compiling mrandersonf3f583ec.camel-snake-kebab.v0v4v0.camel-snake-kebab.internals.misc
Compiling mrandersonf3f583ec.camel-snake-kebab.v0v4v0.camel-snake-kebab.internals.string-separator
Compiling mrandersonf3f583ec.camelsnake.v0v10v0.camelsnake.core
Syntax error macroexpanding at (core.clj:18:1).
Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:387).
fullaws100SNAPSHOT.fullaws100SNAPSHOT.camelsnake.Converter

Full report at:
/tmp/clojure-6394218391740156539.edn
Compilation failed: Subprocess failed (exit code: 1)
Error encountered performing task 'test' with profile(s): 'base,system,user,provided,dev,config'
Compilation failed: Subprocess failed (exit code: 1)

Mor Gazith18:01:42

Compiling mranderson5b5c66f9.javaclasspath.v0v2v3.clojure.java.classpath
Compiling mranderson5b5c66f9.fulljson.v0v12v0.full.json
Syntax error macroexpanding at (factory.clj:1:1).
Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:382).
fullaws100SNAPSHOT.com.fasterxml.jackson.core.JsonFactory

Mor Gazith18:01:17

we both get ClassNotFoundException but for different classes, i assume because of parallelism going on?

lread18:01:14

maybe? here's my lein version, what's yours?

❯ lein --version
Leiningen 2.9.10 on Java 1.8.0_352 OpenJDK 64-Bit Server VM

Mor Gazith18:01:45

Leiningen 2.8.3 on Java 1.8.0_191 Java HotSpot(TM) 64-Bit Server VM

lread18:01:17

Hmm... any reason you are running an old version of lein? Can you bump to current?

Mor Gazith18:01:31

i’ve tried at some point planting lein script with updated version in the repo and used that, didn’t help

Mor Gazith18:01:15

let me update now

Mor Gazith18:01:27

ok, i’m at:

Leiningen 2.10.0 on Java 1.8.0_191 Java HotSpot(TM) 64-Bit Server VM

Mor Gazith18:01:59

Compiling mranderson5b5c66f9.camelsnake.v0v10v0.camelsnake.core
Syntax error macroexpanding at (core.clj:18:1).
Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:382).
fullaws100SNAPSHOT.fullaws100SNAPSHOT.camelsnake.Converter

Mor Gazith18:01:16

same result as yours

Mor Gazith18:01:45

oh, ok, this is the issue where is duplicates the prefix 2 or more times on many sources

Mor Gazith18:01:53

i workaround it via search & replace

Mor Gazith18:01:20

(fullaws100SNAPSHOT\.){2,} => fullaws100SNAPSHOT.

Mor Gazith18:01:24

now i’m back at:

Syntax error macroexpanding at (factory.clj:1:1).
Execution error (ClassNotFoundException) at java.net.URLClassLoader/findClass (URLClassLoader.java:382).
fullaws100SNAPSHOT.com.fasterxml.jackson.core.JsonFactory

Mor Gazith18:01:12

under target/srcdeps/fullaws100SNAPSHOT/com/fasterxml/jackson i don’t have “core” only “dateformat”

Mor Gazith18:01:05

i really appreciate you taking the time to investigate by the way 🙏

lread18:01:31

my pleasure

lread18:01:20

I am not sure how many problems we are dealing with here yet. I think dealing with one minimal reproducible problem at a time is the only way to proceed. For me, a first exploration might be attempting to create a minimal repo of the weird looking fullaws100SNAPSHOT.fullaws100SNAPSHOT.camelsnake.Converter reference.

Mor Gazith19:01:28

sure, i agree

lread19:01:24

Hmm... I wonder if :aot :all is problematic? Frankly don't know at this point.

Mor Gazith19:01:52

without :aot it seems to compile

Mor Gazith19:01:37

hmmm… under com/fasterxml/jackson i still don’t see “core”… wonder why

Mor Gazith19:01:41

question, now that the dep full.json is shaded (hopefully correctly) do i need to manually update references to full.json in my code to point to mrandersona1575b6b.full... ?

lread19:01:29

but without :aot :all are things loading/compiling when launching test on a project without tests?

lread19:01:58

no, I don't think you should need to update references to full.json , the inlining should take care of renaming the inlined ns and any references from your code to that inlined ns.

Mor Gazith19:01:10

but it doesn’t, the code in full.aws/sqs.clj still requires [full.json]

lread19:01:04

Hmm... I'll run it here and see what I can see.

👍 2
lread21:01:56

Well, something seems amiss... I think an sqs.clj should be generated under target/ with the reference changed... I'll have a deeper look (probably) tomorrow.

lread17:01:00

Ok, so problem 1 of n might be related to :aot :all , will recheck that later, but for now, we'll not do that. Problem 2 of n seems to be that MrAnderson is deleting the full directory that it generated under target/srcdeps . It does not take into account that a lib that you are inlining might share the same root namespace as the project you are inlining from. In our latest test case: full.aws is inlining full.json. If I rename nses under src in the full.aws lib from full.* to notfull.* I see ./target/srcdeps/notfull.* generated as expected. I'll raise this as an issue on MrAnderson.

lread17:01:05

@U04H5V7URR9 what if your GitHub user id? If you are ok with it, I'd like to reference it in the issue.

Mor Gazith17:01:45

sure, I'm at @marmor7

👍 2
Mor Gazith17:01:45

wow, good catch!

lread19:01:24

@U04H5V7URR9 side note: isn't it a bit odd that fullcontact libraries include .class files? That's typically not a good practice for a library, is it?

lread19:01:53

I'm looking at full.core-1.1.1.jar and it seems to include .class files for its sources and all its deps.

lread19:01:14

And same for full.json-0.12.0.jar. Could this be contributing to your jackson dependency hell issues?

Mor Gazith20:01:25

i have no idea about that… i that related to the :oat thing? maybe jvm is compiling all java imports to class files and adding them to the resulting jar?

Mor Gazith20:01:37

is there something in the lib itself or the compile process that causes those class files to get into the jar file?

lread04:01:57

Yeah it is due to :aot. Folks don't typically aot (compile .clj to .classes) for libraries. They will sometimes aot compile their apps for faster startup.

Mor Gazith11:01:30

i’ll go ahead and open another issue about incompatibility with :aot flag even if not fixed it might help future desperate and confused devs such as myself to figure out the multiple prefix symptom

👍 2
lread21:01:56

Note to all: although I created this channel with his blessing, @benedek is the creator and maintainer of MrAnderson.