Skip to content
This repository has been archived by the owner on Apr 24, 2023. It is now read-only.

Require in components.clj cause compile time error #1370

Open
DaoWen opened this issue Jan 22, 2020 · 2 comments
Open

Require in components.clj cause compile time error #1370

DaoWen opened this issue Jan 22, 2020 · 2 comments
Labels

Comments

@DaoWen
Copy link
Contributor

DaoWen commented Jan 22, 2020

Describe the bug

Adding new line to the :require list in components.clj (which should basically be a no-op) causes a compile-time error.

To Reproduce

Adding this single line to the requires list at the top of components.clj file causes an opaque compile time error when running lein uberjar:

[cook.progress :as progress]
java.lang.RuntimeException: Can't embed object in code, maybe print-dup not defined: clojure.lang.Delay@18c1d366, compiling:(schema.clj:16:1)


Full lein uberjar output:

$ lein uberjar    
Compiling 2 source files to /home/nickv/projects/cook/scheduler/target/classes
warning: No SupportedSourceVersion annotation found on io.sundr.builder.internal.processor.BuildableProcessor, returning RELEASE_6.
warning: Supported source version 'RELEASE_6' from annotation processor 'io.sundr.builder.internal.processor.BuildableProcessor' less than -source '1.8'
warning: No SupportedSourceVersion annotation found on io.sundr.builder.internal.processor.ExternalBuildableProcessor, returning RELEASE_6.
warning: Supported source version 'RELEASE_6' from annotation processor 'io.sundr.builder.internal.processor.ExternalBuildableProcessor' less than -source '1.8'
warning: No SupportedSourceVersion annotation found on io.sundr.resourcecify.internal.processor.ResourcecifyProcessor, returning RELEASE_6.
warning: Supported source version 'RELEASE_6' from annotation processor 'io.sundr.resourcecify.internal.processor.ResourcecifyProcessor' less than -source '1.8'
6 warnings                                                  
Compiling cook.components                               
log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly. 
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
java.lang.RuntimeException: Can't embed object in code, maybe print-dup not defined: clojure.lang.Delay@18c1d366, compiling:(schema.clj:16:1)
Exception in thread "main" java.lang.RuntimeException: Can't embed object in code, maybe print-dup not defined: clojure.lang.Delay@18c1d366, compiling:(schema.clj:16:1)
        at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3657)
        at clojure.lang.Compiler.compile1(Compiler.java:7474)
        at clojure.lang.Compiler.compile1(Compiler.java:7464)
        at clojure.lang.Compiler.compile(Compiler.java:7541)
        at clojure.lang.RT.compile(RT.java:406)                          
        at clojure.lang.RT.load(RT.java:451)            
        at clojure.lang.RT.load(RT.java:419)               
        at clojure.core$load$fn__5677.invoke(core.clj:5893)         
        at clojure.core$load.invokeStatic(core.clj:5892)
        at clojure.core$load.doInvoke(core.clj:5876)                          
        at clojure.lang.RestFn.invoke(RestFn.java:408)    
        at clojure.core$load_one.invokeStatic(core.clj:5697)                      
        at clojure.core$load_one.invoke(core.clj:5692)              
        at clojure.core$load_lib$fn__5626.invoke(core.clj:5737)
        at clojure.core$load_lib.invokeStatic(core.clj:5736) 
        at clojure.core$load_lib.doInvoke(core.clj:5717)    
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:648)                        
        at clojure.core$load_libs.invokeStatic(core.clj:5774)
        at clojure.core$load_libs.doInvoke(core.clj:5758)  
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:648)
        at clojure.core$require.invokeStatic(core.clj:5796)
        at clojure.core$require.doInvoke(core.clj:5796)
        at clojure.lang.RestFn.invoke(RestFn.java:2088)
        at cook.tools$loading__5569__auto____24238.invoke(tools.clj:16)
        at clojure.lang.AFn.applyToHelper(AFn.java:152)
        at clojure.lang.AFn.applyTo(AFn.java:144)
        at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3652)
        at clojure.lang.Compiler.compile1(Compiler.java:7474)
        at clojure.lang.Compiler.compile1(Compiler.java:7464)
        at clojure.lang.Compiler.compile(Compiler.java:7541)
        at clojure.lang.RT.compile(RT.java:406)
        at clojure.lang.RT.load(RT.java:451)
        at clojure.lang.RT.load(RT.java:419)
        at clojure.core$load$fn__5677.invoke(core.clj:5893)
        at clojure.core$load.invokeStatic(core.clj:5892)
        at clojure.core$load.doInvoke(core.clj:5876)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5697)
        at clojure.core$load_one.invoke(core.clj:5692)
        at clojure.core$load_lib$fn__5626.invoke(core.clj:5737)
        at clojure.core$load_lib.invokeStatic(core.clj:5736)
        at clojure.core$load_lib.doInvoke(core.clj:5717)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:648)
        at clojure.core$load_libs.invokeStatic(core.clj:5774)
        at clojure.core$load_libs.doInvoke(core.clj:5758)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:648)
        at clojure.core$require.invokeStatic(core.clj:5796)
        at clojure.core$require.doInvoke(core.clj:5796)
        at clojure.lang.RestFn.invoke(RestFn.java:805)
        at cook.progress$loading__5569__auto____24236.invoke(progress.clj:16)
        at clojure.lang.AFn.applyToHelper(AFn.java:152)
        at clojure.lang.AFn.applyTo(AFn.java:144)
        at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3652)
        at clojure.lang.Compiler.compile1(Compiler.java:7474)
        at clojure.lang.Compiler.compile1(Compiler.java:7464)
        at clojure.lang.Compiler.compile(Compiler.java:7541)
        at clojure.lang.RT.compile(RT.java:406)
        at clojure.lang.RT.load(RT.java:451)
        at clojure.lang.RT.load(RT.java:419)
        at clojure.core$load$fn__5677.invoke(core.clj:5893)
        at clojure.core$load.invokeStatic(core.clj:5892)
        at clojure.core$load.doInvoke(core.clj:5876)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5697)
        at clojure.core$load_one.invoke(core.clj:5692)
        at clojure.core$load_lib$fn__5626.invoke(core.clj:5737)
        at clojure.core$load_lib.invokeStatic(core.clj:5736)
        at clojure.core$load_lib.doInvoke(core.clj:5717)                                                                                                                                                                                                                      [1099/13152]
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:648)
        at clojure.core$load_libs.invokeStatic(core.clj:5774)
        at clojure.core$load_libs.doInvoke(core.clj:5758)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:648)
        at clojure.core$require.invokeStatic(core.clj:5796)
        at clojure.core$require.doInvoke(core.clj:5796)
        at clojure.lang.RestFn.invoke(RestFn.java:3894)
        at cook.components$loading__5569__auto____36.invoke(components.clj:15)
        at clojure.lang.AFn.applyToHelper(AFn.java:152)
        at clojure.lang.AFn.applyTo(AFn.java:144)
        at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3652)
        at clojure.lang.Compiler.compile1(Compiler.java:7474)
        at clojure.lang.Compiler.compile1(Compiler.java:7464)
        at clojure.lang.Compiler.compile(Compiler.java:7541)
        at clojure.lang.RT.compile(RT.java:406)
        at clojure.lang.RT.load(RT.java:451)
        at clojure.lang.RT.load(RT.java:419)
        at clojure.core$load$fn__5677.invoke(core.clj:5893)
        at clojure.core$load.invokeStatic(core.clj:5892)
        at clojure.core$load.doInvoke(core.clj:5876)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5697)
        at clojure.core$compile$fn__5682.invoke(core.clj:5903)
        at clojure.core$compile.invokeStatic(core.clj:5903)
        at clojure.core$compile.invoke(core.clj:5895)
        at user$eval20$fn__29.invoke(form-init6238524710754236363.clj:1)
        at user$eval20.invokeStatic(form-init6238524710754236363.clj:1)
        at user$eval20.invoke(form-init6238524710754236363.clj:1)
        at clojure.lang.Compiler.eval(Compiler.java:6927)
        at clojure.lang.Compiler.eval(Compiler.java:6917)
        at clojure.lang.Compiler.eval(Compiler.java:6917)
        at clojure.lang.Compiler.load(Compiler.java:7379)
        at clojure.lang.Compiler.loadFile(Compiler.java:7317)
        at clojure.main$load_script.invokeStatic(main.clj:275)
        at clojure.main$init_opt.invokeStatic(main.clj:277)
        at clojure.main$init_opt.invoke(main.clj:277)
        at clojure.main$initialize.invokeStatic(main.clj:308)
        at clojure.main$null_opt.invokeStatic(main.clj:342)
        at clojure.main$null_opt.invoke(main.clj:339)
        at clojure.main$main.invokeStatic(main.clj:421)
        at clojure.main$main.doInvoke(main.clj:384)
        at clojure.lang.RestFn.invoke(RestFn.java:421)
        at clojure.lang.Var.invoke(Var.java:383)
        at clojure.lang.AFn.applyToHelper(AFn.java:156)
        at clojure.lang.Var.applyTo(Var.java:700)
        at clojure.main.main(main.java:37)
Caused by: java.lang.RuntimeException: Can't embed object in code, maybe print-dup not defined: clojure.lang.Delay@18c1d366
        at clojure.lang.Util.runtimeException(Util.java:221)
        at clojure.lang.Compiler$ObjExpr.emitValue(Compiler.java:4810)
        at clojure.lang.Compiler$ObjExpr.emitListAsObjectArray(Compiler.java:4621)
        at clojure.lang.Compiler$ObjExpr.emitValue(Compiler.java:4752)
        at clojure.lang.Compiler$ObjExpr.emitValue(Compiler.java:4741)
        at clojure.lang.Compiler.compile(Compiler.java:7578)
        at clojure.lang.RT.compile(RT.java:406)
        at clojure.lang.RT.load(RT.java:451)
        at clojure.lang.RT.load(RT.java:419)
        at clojure.core$load$fn__5677.invoke(core.clj:5893)
        at clojure.core$load.invokeStatic(core.clj:5892)
        at clojure.core$load.doInvoke(core.clj:5876)
        at clojure.lang.RestFn.invoke(RestFn.java:408)
        at clojure.core$load_one.invokeStatic(core.clj:5697)
        at clojure.core$load_one.invoke(core.clj:5692)
        at clojure.core$load_lib$fn__5626.invoke(core.clj:5737)
        at clojure.core$load_lib.invokeStatic(core.clj:5736)
        at clojure.core$load_lib.doInvoke(core.clj:5717)
        at clojure.lang.RestFn.applyTo(RestFn.java:142)
        at clojure.core$apply.invokeStatic(core.clj:648)
        at clojure.core$load_libs.invokeStatic(core.clj:5774)
        at clojure.core$load_libs.doInvoke(core.clj:5758)
        at clojure.lang.RestFn.applyTo(RestFn.java:137)
        at clojure.core$apply.invokeStatic(core.clj:648)
        at clojure.core$require.invokeStatic(core.clj:5796)
        at clojure.core$require.doInvoke(core.clj:5796)
        at clojure.lang.RestFn.invoke(RestFn.java:421)
        at cook.schema$loading__5569__auto____24240.invoke(schema.clj:16)
        at clojure.lang.AFn.applyToHelper(AFn.java:152)
        at clojure.lang.AFn.applyTo(AFn.java:144)
        at clojure.lang.Compiler$InvokeExpr.eval(Compiler.java:3652)
        ... 119 more
Compilation failed: Subprocess failed

Expected behavior
lein uberjar should complete successfully even if the cook.progress module is required in components.clj.

Additional context

I suspect that the error is triggered by mount for two reasons.

  1. It's a compile time error
  2. The adjacent require lines have commitments like the following:
            ; This explicit require is needed so that mount can see the defstate defined in the cook.rate-limit namespace.                                                                                                                                                                
            ; cook.rate-limit and everything else under cook.rest.api is normally hidden from mount's defstate because                                                                                                                                                                    
            ; cook.rest.api is loaded via util/lazy-load-var, not via 'ns :require'                                                                                                                                                                                                       
            [cook.rate-limit]

Since we're able to work around this by using our lazy-load-var utility function to load the function we need, and it's only invoked once at graph-compile time, I'm not digging into this any further at this time.

@DaoWen DaoWen added the bug label Jan 22, 2020
@scrosby
Copy link
Member

scrosby commented Sep 29, 2020

I ran into this problem in a way that I couldn't avoid. I traced it to some kind of incompatability with metatransactions and mount. If your dependency tree (that mount) traverses includes metatransactions.core anywhere, we get this breakage. We should revert our lazy-load-var code now that we've identified this problem. Metatransaction is almost dead. So we can workaround this by killing it off more fully gradually.

@DaoWen
Copy link
Contributor Author

DaoWen commented Sep 30, 2020

@scrosby - Good find! I bet this is related to the #db/fn and #db/id tagged-literals def'd in metatransactions.core. I did a bit of Googling and found boot-clj/boot#47, which seems related. It affects boot rather than mount, but they both seem like weird meta-language dependency issues. We could work around this by making those defs lazier — but like you said, it's probably not worth the effort since we're slowly killing that api.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants