Eiji

Eiji

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?

Showing Posts 1 to 4

hauleth

hauleth

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

Eiji

Eiji OP

No matter if mnesia or other solution I need to save some data on compile time. It could look weird, but it’s my private project assumption. I don’t want to describe everything now. In short I want to store some data and later use them dynamically.

For simplicity imagine that every time you call use Ecto.Repo module (as __MODULE__ in __using__/1 is saved as key in repositories table, so it could be later used to dynamically fetch all project repositories without setting them in config :my_app, :ecto_repos, […] manually. Of course my case is much more bigger than single key mnesia table - it’s just to show an example of storing some things on compile time which could be fetched dynamically.

To be honest it’s also not even a big priority for me. I just found that mistake like removing mnesia directory manually or by mix task causes problem, because I can’t recompile and re-fill database.

dimitarvp

dimitarvp

Have you tried replacing your compile-time inserting in a database with a mix task? That could help you with testing it as well.

Eiji

Eiji OP

@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:

— All posts loaded —

Where Next? Top

Trending in Questions Top

katta
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
brecabral
Documentation While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
nseaSeb
Hello, I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
kpanic
Hi everyone, I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding. I sta...
New
velrest
So my question is quite simple and i have found no conclusive answer on forum, google or AI. Should we use :erlang.float for Integer to ...
New
asweet-confluent
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apz
I’m new to elixir and just tried to install the elixirLS extension for VScode(ium) and it is throwing some errors that I would like help ...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews