michaelterryio

michaelterryio

Hey,

I’ve got a project with several path dependencies. Some are phoenix apps, but this likely isn’t relevant.

I don’t fully understand the following behavior.

If I make a change in a file in a path dependency and run iex -S mix phx.server, the file is recompiled.

But if I make a change in a file in a path dependency while iex is already running, the file is not recompiled.

I know I can use r() on a particular module, but that’s not quite as convenient. Is there an easy way to get recompile to work on changed files in path dependencies?

Showing Posts 1 to 4

NobbZ

NobbZ

Recompile does only ever recompile modules of the current application/project.

In my opinion, you should not rely on anything to recompile your dependencies, except for mix deps.compile --force.

axelson

axelson

Scenic Core Team

You could try out exsync for your code reloading:

It will recompile path dependencies for you when you make the changes.

delameko

delameko

As this is a top result on Google when searching for auto recompiling dependencies, I just wanted to leave a solution that doesn’t require a third party library (not sure if this was possible when the question was originally asked). This is for Phoenix apps running live_reload, if not, then exsync is still a good option.

You’ve got two projects my_app and my_dep. In my_app/mix.exs you’ve got:

    defp deps do
      {:my_dep, path: "../my_dep"}
      ..
    end

In your config/dev.exs:

    config :my_app, MyApp.Endpoint,
      live_reload: [
        patterns: [
          # make sure you have patterns that work for either app, they should be relative 
          # to the root of a project, the same pattern can match both apps. 
          # So don't do '~r"../core_dep/priv"', that'll be ignored, do: '~r"priv"'
        ]
      reloadable_apps: [:my_dep, :my_app]

and

    parent_path =
      __ENV__.file
      |> Path.dirname()
      |> Path.join("../..")
      |> Path.expand()

    config :phoenix_live_reload, :dirs, [
      Path.join([parent_path, "my_dep"]),
      Path.join([parent_path, "my_app"])
    ]

Now your webpage update with changes made to either app.

axelson

axelson

Scenic Core Team

Yeah I don’t think reloadable_apps existed at that time. But it is definitely a great to have available to you! Although a small note is that it doesn’t change the behavior of the IEx.Helpers.recompile command, instead you’ll have to be sure that you trigger Phoenix.CodeReloader (which is separate from phoenix_live_reload) by reloading a page in your Phoenix app.

— All posts loaded —

Where Next? Top

Trending in Questions Top

Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
jaybe78
Hello, I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter). The diffic...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
matt-savvy
Anyone here using Honeybadger? My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of Bandit.HTTPError...
New
RemyXRenard
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews