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

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
logicmason
Hi there, I'm working through my first release with elixir/phoenix. I've built a release with distillery and found that it crashes when I...
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
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
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
Mooodi
Given a string, how can I get access to its character by index? Enum.at("my_string", 2) doesn't work. Or rather, not char, but a substr...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
idi527
I’ve been re-reading swift book again and noticed that multiline strings there don’t have a trailing line break, unlike in elixir iex(2)...
New

Other popular topics Top

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
Jim
As a follow up to my earlier question: I have the code compiling and running but not getting a successful login from the rest server. ...
New
fireproofsocks
I’m working on defining a simple Ecto schema for a table (in PostGres), but I don’t see where I can define a column as NOT NULL. Conside...
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
fayddelight
I tried installing elixir 1.11.2 erlang 23.3.4 via asdf in my zsh shell. Enabled the versions locally and globally. When I list them ...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
AstonJ
We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including. What is Phoenix LiveV...
New
Nvim
Elixir appears to be a superior language to Python. I don’t see any advantage of Python over Elixir. Are there any?
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement