tolitius / mount

managing Clojure and ClojureScript app state since (reset)
Eclipse Public License 1.0
1.22k stars 88 forks source link

weird compilation issues when using aot w/use of defstate macro #73

Open mgrbyte opened 7 years ago

mgrbyte commented 7 years ago

Hi, We're using mount to handle a single connection to a datomic database in our app, and recently ran into an issue. To fully describe what's happening here:

Switching between the two branches and issueing any lein repl/run/ring command will cause re-compilation to be attempted, which triggers the error linked to above. In order to work around the error, the following steps "work around" the issue:

  1. switch git branch
  2. run lein .... (ClassDefNotFound error is thrown pointing at mount/core/DeferrableState | defstate macro)
  3. touch -m <path to db.clj>
  4. run lein (works again)

Repeating steps 0 .. 3 (on a different branch where db.clj is re-located) re-produces the error consistently.

Investigating further, my colleague found that disabling aot compilation also works-around this issue.

I found this which seems to indicate that this could be the cause of the issue here.

Specifically, the following passage was an "ah-ha!" moment:

set-logger! is a macro that makes use of the ns var. ns contains the current namespace and, due to what I’m assuming to be special semantics regarding this particular var, it shouldn’t be unquoted within a macro - which is why it was failing in AOT mode.

(Our project.clj is currently using aot compilation)