Eiji

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

Eiji

@dimitarvp: Oh, I’m really sorry for delay. I was a bit busy last time. :slight_smile:

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. :smiley:

Anyway thank you all for help. I though that some code is seriously not called again using force argument. Fortunately I was wrong. :077:

Also Liked

hauleth

hauleth

Dear gods, it is absolutely terrible. Before going anywhere from there, let me just ask: WHY?

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New

Other popular topics Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40165 209
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New

We're in Beta

About us Mission Statement