Unfriendly Java cast expection when *compile-path* is set incorrectly


When compile-path is not set to a String but to a java.io.File (that's what boot-clj does at the moment). You get a Cast exception in the compiler when trying to use it from the boot repl. Common wisdom seems to be to not compile from the repl, people say don't use gen-class. I find this unfortunate for when you do want to use gen-class and iterate quickly.

I haven't tested all older versions for this issue, but git blame shows that the code that should help here wasn't changed for 10 years:

My workaround now is:

I suggest to put the type check in the 'clojure.core/compile function.


Mac OS, boot-clj


Jeroen van Dijk
October 5, 2018, 9:12 AM

I've tried to make the example as simple as possible. You are right that the ClassCastException is perfectly accurate, but you realise this only after you have figured out it's about compile-path. This bug report is mostly about managing expectations (of the clojure user).

Alex Miller
October 4, 2018, 7:13 PM

Can you provide a reproducible example?

Seems like ClassCastException is pretty accurate for having a class of the wrong type.

Jeroen van Dijk
October 4, 2018, 12:01 PM

The following works in boot-clj (because of classpath issues not in Leiningen and clj cli): https://gist.github.com/jeroenvandijk/8187413d24433545eeb9579538a903f7#file-repl_compile-clj-L39-L52

Jeroen van Dijk
October 4, 2018, 10:13 AM
Your pinned fields
Click on the next to a field label to start pinning.




Jeroen van Dijk