This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
- # announcements (6)
- # asami (1)
- # babashka (80)
- # beginners (89)
- # bitcoin (1)
- # calva (30)
- # cider (33)
- # clj-kondo (1)
- # clj-new (29)
- # cljsrn (45)
- # clojars (5)
- # clojure (60)
- # clojure-australia (1)
- # clojure-dev (9)
- # clojure-europe (133)
- # clojure-italy (7)
- # clojure-nl (6)
- # clojure-uk (44)
- # clojurescript (11)
- # conjure (1)
- # crux (7)
- # data-oriented-programming (2)
- # datahike (13)
- # datascript (4)
- # datomic (19)
- # depstar (5)
- # duct (39)
- # fulcro (8)
- # girouette (1)
- # helix (10)
- # honeysql (17)
- # jobs (5)
- # jobs-discuss (2)
- # leiningen (6)
- # lsp (51)
- # malli (60)
- # meander (37)
- # membrane (8)
- # off-topic (31)
- # overtone (3)
- # pathom (36)
- # re-frame (8)
- # reagent (30)
- # remote-jobs (2)
- # sci (1)
- # sql (32)
- # startup-in-a-month (3)
- # testing (3)
- # tools-deps (7)
We have a project at work that uses hugsql with clojure.java.jdbc. To deploy in production we do AOT but last night we got a CompilerException:
CompilerException: Syntax error compiling at (hugsql/adapter/clojure_java_jdbc.clj:11:7). ... RuntimeException: No such var: jdbc/db-do-prepared-return-keys at clojure.lang.Util.runtimeException(Util.java:221) at clojure.lang.Compiler.resolveIn(Compiler.java:7388) at clojure.lang.Compiler.resolve(Compiler.java:7358) at clojure.lang.Compiler.analyzeSymbol(Compiler.java:7319) at clojure.lang.Compiler.analyze(Compiler.java:6768)
Has anyone seem that before or has any lead of how to debug this? A related question: should be a java class for each aot compiled clojure namespace? I looked at the uberjar but found the structure way different than I expected but that may be just my ignorance of what should be in there.
The code is is production for a long time and we never saw that error before. What changed a couple of months ago is the addition of AOT.
aot compilation has a habit of shaking and weird unexpected things in your code base
two places to start on your error would be making sure you don't have any stale class files laying around (class files generate from previous aots), and checking your dependency tree to see if you are somehow pulling in a different version of clojure.java.jdbc than expected
@hiredman thanks for taking the time to respond. It happened when running. The uberjar is built on a ci server so no stale classes should be possible. I will check the dependency tree.
the next thing to do will be to look at your dependencies to make sure none of them are aot compiled with an older version of jdbc
(since it is coming from the compiler, which shouldn't happen if everything is aot compiled)
when you aot what you should get out is to some degree a function of what your build tool is, and how it manages its aot feature
Ok, thanks for the direction. Will report back what I find. I found some
.clj files on the uberjar, not sure if those are expected. I'm using depstar to create the uberjar.
Especially since that function --
db-do-prepared-return-keys -- has been in c.j.j for a long time and hasn't been touched since that 0.7.6 release.
the way the clojure compiler handles it is all the code loaded while aot compiling generates classes
so for example, if you are preloading any code before triggering aot compilation, it won't be aot compiled unless you reload it, which can be a problem
@mynomoto Yes, if there are paths in the code that do not statically reference certain namespaces, those will not be AOT compiled for just
depstar. You could try
com.layerware/hugsql 0.4.9 I checked the changelogs over there but I didn't find anything suspicious.
That should be recent enough to be fine. I would check your dependencies with
clojure -Stree and see if older versions are lurking elsewhere in your transitive deps.
I just did that as suggested by @hiredman but there is only one reference both to clojure.java.jdbc and hugsql.
You might try
hugsql 0.5.1, since there was a fix related to requiring and setting the adapter that might help with AOT issues.
I think this commit that was released on 0.5.0 was the one that fixed the issue but caused the bug that was fixed in 0.5.1 https://github.com/layerware/hugsql/commit/8a908f7a5de37d232183a3bebc2f9e4ab26812a3