leiningen

Tomasz Kontusz 2022-10-23T11:33:39.668179Z

I have a problem with lein javac that I don't know how to approach: I've made a user.clj with some repl helpers, which imports my main application. This application uses a few Java classes. When the classes are already compiled, I can run lein javac. When I remove the classes then lein javac crashes with ClassNotFoundException when importing my main namespace. When I comment out all code in my user.clj it works again.

Tomasz Kontusz 2022-10-23T11:34:26.973239Z

Is leiningen always loading the user namespace? I've assumed it's only used for the REPL, am I wrong?

vemv 2022-10-23T11:51:06.423719Z

Clojure always loads user.clj (before anything else!) if it is in your classpath

vemv 2022-10-23T11:51:22.476399Z

it has that special semantic

vemv 2022-10-23T11:52:53.920879Z

assuming that user.clj resides in dev/ which is added by a :dev profile, you could run: lein with-profile -dev javac ...that's meant to be effectively equivalent to "commenting out user.clj" :)

Tomasz Kontusz 2022-10-23T11:54:31.982749Z

Oh, that makes sense! I'll move my repl tools to another namespace, user.clj is just not the right place for them.

👍 1
vemv 2022-10-23T11:55:26.984239Z

yeah I have them in dev/dev.clj

Tomasz Kontusz 2022-10-23T11:55:44.247979Z

Thank you! I was starting to doubt my senses (the REPL would start sometimes, crash sometimes, or my favourit: Cursive would hang on something like "Calculating Classpath")

1
vemv 2022-10-23T11:55:44.390759Z

...this "special semantic" has all sorts of unintended side-effects 🙃