It may be hard to tackle this. For example, adding a dependency may cause other dependencies to be recompiled. That’s ok, but if those dependencies have already been running, then we need to shut down applications, purge modules and state, etc.
Therefore we can make this work for certain cases. It really depends on how much code has been loaded at the time the command is invoked. Generally speaking, it is easier to make it work if “mix deps.add —install” was part of Elixir, because we could then call it without loading much else. However, I don’t know how hard would be to implement this in practice without porting tools like sourceror. If it is only a small part of it, it would be fine. On Tue, Jul 30, 2024 at 21:05 Zach Daniel <zachary.s.dan...@gmail.com> wrote: > Hey folks! > > In igniter, a core concept we have is `mix igniter.install dep`, which > patches the `mix.exs` file, recompiles the app accordingly, and then looks > for a mix task called `mix <dep>.install`, and invokes it. There are lots > of other features, but this is the crux of it. > > In an ideal world, I could patch the `mix.exs` file with a new dependency > and run `Mix.Tasks.run("deps.compile")`. > > What we're doing now: > > I don't necessarily want to dive too deep into what I'm currently doing, > as we do have something working (but far from ideal) but its through a lot > of trial and error is a bit of a mess. It also recompiles every dependency > every time. I'd much rather revisit this from a fresh perspective. > > So with that in mind, what would the recommended way to approach this idea > be? > Specifically, how could I write a mix task that can patch the `mix.exs` > file, and then compile the new dependency or dependencies? > > -- > You received this message because you are subscribed to the Google Groups > "elixir-lang-core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to elixir-lang-core+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/elixir-lang-core/20c0edaf-60ef-464e-80f8-37734c67ce19n%40googlegroups.com > <https://groups.google.com/d/msgid/elixir-lang-core/20c0edaf-60ef-464e-80f8-37734c67ce19n%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "elixir-lang-core" group. To unsubscribe from this group and stop receiving emails from it, send an email to elixir-lang-core+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/elixir-lang-core/CAGnRm4LFnDMfC7jMrdE5-YgcLt%3DaXbcmEkPQR0O5GZrp2wVF5Q%40mail.gmail.com.