aesmail

aesmail

Compiling and loading modules dynamically

I have a bit of an unconventional situation.

I have an app that generates files at runtime. Those files contain valid elixir code (modules basically). I need to compile them and load them at runtime.

I am able to do most of that with Code.compile_file, Code.require_file, and friends.

However, I need to be able to check what new modules have been compiled (or all the modules currently loaded in my app).

I’m using :application.get_key(:my_app, :modules) which lists all modules correctly when the app starts, but this doesn’t include the newly compiled modules at runtime.

Any idea how to achieve that?

All I care about is, I need to compile random modules at runtime and I need to know about all the newly generated modules that were compiled randomly at runtime.

Thanks!

Most Liked

OvermindDL1

OvermindDL1

Personally I’d have the files register themselves, you might have tools and such you don’t want loaded via your normal way as well after all. :slight_smile:

dimitarvp

dimitarvp

I seem to remember the core team saying that there are compiler callbacks or some such now but I am not able to immediately find anything on it.

xlphs

xlphs

If you only care about newly compiled modules, and your app is the one that compiles and loads each module, you can store each module name or the file name into an Agent or your own GenServer.

Last Post!

zaherh8

zaherh8

hello @aesmail, any luck with finding a way to load the newly compiled modules?
I am facing the same case where I need to compile different modules dynamically. I need to make sure that the modules are loaded and accessible. If you found any result please share thanks.

Where Next?

Popular in Questions Top

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
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
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
stefanluptak
Hello everybody, usually, I use a 29" ultra-wide monitor for VSCode which can easily accomodate explorer (files panel) + file with code ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
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

Other popular topics Top

joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1144 54921 245
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
sorentwo
Hello! tl;dr Announcing Oban, an Ecto based job processing library with a focus on reliability and historical observability. After spen...
985 44532 311
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New

We're in Beta

About us Mission Statement