This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-01-09
Channels
- # announcements (9)
- # babashka (14)
- # beginners (27)
- # biff (4)
- # calva (3)
- # cider (14)
- # clojure (36)
- # clojure-austin (1)
- # clojure-europe (43)
- # clojure-japan (4)
- # clojure-nl (2)
- # clojure-norway (59)
- # clojure-uk (6)
- # clojurescript (13)
- # conjure (2)
- # data-science (3)
- # datomic (3)
- # deps-new (40)
- # hyperfiddle (72)
- # jobs (2)
- # lsp (8)
- # malli (10)
- # missionary (3)
- # off-topic (22)
- # overtone (3)
- # reagent (12)
- # releases (1)
- # squint (1)
Can anyone check their code-bases for usages of clojure.reflect
and what functions from that namespace you use? ๐งต
I wonder if anyone uses more than just reflect/reflect.
Upvote this message if you're only using reflect/reflect
, specify others in thread below

@U23DRD8FN "and what functions from that namespace you use"?
@U0P0TMEFJ what did you mean with the ?
please be explicit about what functions exactly you are using if more than just reflect
https://grep.app/search?q=reflect/&filter[lang][0]=Clojure
looks like mostly just reflect/reflect
, though there is at least one use of reflect/typename
Is it possible to avoid loading user.clj
when the containing directory is on the classpath? i only want user.clj
to be loaded when starting a repl
Put it in a dev
folder and use an alias when starting a REPL that has :extra-paths ["dev"]
it's actually an issue with running the tests with -M:dev:test:runner
(where :dev
has "dev", :test adds "tests", and :runner has the main-opts). i have some both dev and test related functions in the dev directory, but it seems one of my dev dependencies doesn't compile correctly, so I'm struggling to use :gen-class
in my main namespace. an annoying situation to be in lol
or, just don't ever use user.clj :)
i'm also considering that too
I recommend a dev.clj
instead of the usual user.clj
, which can easily be used from the repl, but which must manually be invoked to resolve this exact issue.
that's clever, thanks
If loading it takes a long while too then you can throw a (println (char 7))
in there as well right at the end of the file so that you get a bel character printed, and if you've got your terminal or editor configured to notify on bel, then it can help get your attention too.
My issue is just a combination of requiring a dev library that can't be compiled, with :gen-class
in my main namespace
I don't think you really understand the issue you are having, because I would be really surprised if the :gen-class directive in an ns form had anything to do with it
๐คท maybe not. if i remove (:gen-class)
from the main namespace (the namespace with -main
in it), then everything works. if I remove the specific libraries from the :require
block in my user.clj
file, then everything works. if i have both, then running clojure -M:dev:test:runner
fails with ClassNotFoundException
pointing at the main namespace
The issue is likely to be actually something like your user.clj is loading some library before clojure.core/compile is called causing that library to be skipped when doing transitive aot compilation
Ah, yeah, you are loading stuff in user.clj before compilation, and compilation is a side effect of loading, and already loaded stuff doesn't get reloaded, so if it is already loaded it won't be aot compiled
So the other option is don't transitively load stuff from user.clj, use requiring-resolve, etc
thanks for the details, that's helpful to know
user.clj
seems to be such a footgun... there are so many "issues" that we see here on Slack with people running into problems like these:slightly_frowning_face:
Part of me wonders if it would be a good idea to have the code that loads the user namespace file print a warning if it finds the file before it actually loads it.
Well, the people who run into trouble expect it to be loaded so I don't think that would help.
The problems aside from what they put in user.clj
it is strange to me that it's loaded first, but I guess it must be, otherwise, how would it be inserted into the chosen namespace?
No, like a warning saying "loading a user.clj is a dangerous operation. It may cause your repl to fail to start if issues exist elsewhere. It is recommended you migrate to a namespace which is not automatically loaded."