lud

lud

Mix.Task.run("app.config") prevents mix task code from being loaded

On Elixir 1.15, calling Mix.Task.run("app.config") prevents calling other modules from my tool.

The tool is installed globally with mix archive.install --force.

In my task run/1 callback, if I call some other module before app.config is called, then the module is loaded in memory and stays available. But if the app.config call happens before, then the module cannot be found.

It looks like app.config erases the load path or something like that.

It worked correctly on Elixir 1.14.

(On a side note I realized that I do not need that code anymore, since the config for the tool is defined in mix.exs ^^’ )

First Post!

lud

lud

Trying back on Elixir 1.14 and the task does not work without running app.config (could not load modules from :my_app, Are you in a mix project?).

Is there some change in this behaviour for Elixir 1.15? I am not sure when reading the changelog.

Edit: hmmm it seems that app.config is always required even in Elixir 1.15, I don’t know what happened before. But I still have that bug where the code of the globally installed task is not available anymore after app.config.

Last Post!

lud

lud

I have this workaround for now:

    {__MODULE__, _, cpath} = :code.get_object_code(__MODULE__)
    dir = Path.dirname(cpath)
    Mix.Task.run("app.config")
    Code.prepend_path(dir)

Where Next?

Popular in Questions Top

vegabook
I’m brand new to Phoenix and I have stripped one of the demo applications to the bone. I just want to get an svg up on the screen. Here i...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Lily
In templates/appointment/index.html.eex: <%= for appointment <- @appointments do %> <tr> <td><%= appoi...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
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

Other popular topics Top

KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36820 110
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
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
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 44265 214
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement