Eiji
Problems with compile time macro caching
Hey, I have really weird problem. I’m working on something which have task to create mnesia database and would require to call use few times. At compilation time (in __using__/1 macro) I’m saving some things into database. If database is not yet created I’m skipping database-specific work and simply use IO.warn/1.
The problem is that when (after previous compilation) I’m creating database and then I’m running mix compile --force then it looks like that macro is called, but there are no entries in database.
When I update macro by simply adding some IO.inspect or IO.puts (for debugging purposes) then after compilation it suddenly works, so it looks like that some piece of code is cached and not running on compile time even if I force project compilation. Of course calling task before final project compilation solves the problem, but again I can’t drop mnesia database and force recompile project.
Is there an option to fully recompile project or at least only every module which uses specific module?
Marked As Solved
Eiji
@dimitarvp: Oh, I’m really sorry for delay. I was a bit busy last time. ![]()
Even before you wrote this I have already found a solution. I made a stupid mistake with check if database is working. After updating code compilation does not skip important code which saves my information to mnesia database.
Answering your question. In my specific case I can’t moved code to mix task. In mix task I have only creating database. Inserting data to tables happens at compile time. Of course I could do it with some example data, but even doing that I would not copy copy which checks if database is working (because in this task I’m already creating it and ensuring its started), so I would not even reproduce problem. ![]()
Anyway thank you all for help. I though that some code is seriously not called again using force argument. Fortunately I was wrong. ![]()
Also Liked
hauleth
Dear gods, it is absolutely terrible. Before going anywhere from there, let me just ask: WHY?







