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

+7 votes
in Clojure by

The auto-loading of user.clj seems to be a "foot gun" that regularly catches people, based on threads on Slack (and elsewhere), so it seems like it would be nice to have some sort of option to disable it when running a Clojure process.

Just today, someone tested the add-lib feature of Clojure 1.12 Alpha 2 and it wasn't working because they had a user.clj that printed a message and the new invoke-tool API didn't like the extra output from user.clj that appeared.

1 Answer

0 votes
by

I would like to understand more about the actual problem

by
This was the specific thread on Slack that caused me to finally create this Ask:

https://clojurians.slack.com/archives/C03RZGPG3/p1681479315972099

But I've seen quite a few people run into issues over ime where the auto-loading of user.clj has caused problems that are often hard to debug. Here's another thread:

https://clojurians.slack.com/archives/C053AK3F9/p1678794628860199

I guess I see about once every month or two on Slack, someone runs into something unexpected with it (I just searched back into the middle of last year). Sometimes they have user.clj in src intending to put specific dev-related tooling in it, and it gets loaded when they try to run their program or, worse, built into an application JAR and run in a non-dev setting -- because it's not clear that the "right" way to use it is to put it somewhere like dev/user.clj and use aliases (or profiles for Leiningen) as a way to ensure it's only loaded when needed.

My thinking was that a JVM property to turn that auto-loading off might make it easier to debug these situations and provide a way to ensure that a stray user.clj accidentally packaged in a third-party library doesn't mess up your application.
...