Mix phx.server does not recompile on changes!

Hi all.
Quick question.

I have a phoenix app which does not recompile when I change any elixir code in dev mode. What could I have screwed up? :slightly_smiling_face:

If I change something and type recompile in iex in returns :noop. I am however able to recompile single modules using r Module manually.

I’m running Phoenix 1.4 and Elixir 1.7 on macOS Mojave.

Thanks in advance

  1. What editor are you using (there are known issues with vim and one of its plugins)
  2. Have you installed the dependencies to make filesystem watching work? I’m not sure if there is a fallback to FS polling when the necessary tools arent available.

1: VSCode right now
2: What dependencies? :slight_smile: I’ve never had this issue with other Phoenix projects

I’ve got phoenix_live_reload installed!

If other projects on the same computer work, then you probably have the system level dependencies.

Then I’d try the usual, simply remove deps and _build folder and try again.

I removed deps and _build which forced it to recompile a file system watcher. But it still doesn’t recompile on changes :cry:

Actually it seems to have been solved now. I assume thanks to your advice. Thanks :slight_smile:

Nope. The root cause seems to be that I ran it in a tmux session.

Huh? I run through tmux excessively, nor do I see any way that tmux would cause such an issue, can you elaborate more? o.O?

1 Like

Well it turned out to just be a coincidence that it worked without tmux. It seems to work sometimes. It is really annoying. So Views are recompiled on change but controllers and other application code are rarely.

In my experience changes to the controllers usually recompile when the page is reloaded, but the controllers don’t recompile directly after code changes because they aren’t being watched for changes by live_reload, but if needed, you should be able to add them in config/dev.exs.

# config/dev.exs

# Watch static and templates for browser reloading.
config :my_app, MyApp.Endpoint,
  live_reload: [
    patterns: [
+     ~r{lib/my_app_web/controllers/.*(ex)$},


I’m guessing they were excluded from the live_reload patterns for a reason. Too many errors that way maybe? :man_shrugging:


Yeah I did not explain my self properly. It does not recompile controllers and any app code in lib/app on reload. That is the problem. Views are properly compiled on change.

It seems like Elixir doesn’t know that any files has changed. If I type recompile in iex I get :noop sometimes.

What IDE and plugins is being used? This sounds like what happens when multiple things are touching the _build directory.

I was able to reproduce the bug when using both Vim and vscode. Vim I’ve been using for many years and I’ve never had this issue. So I can’t see it being the cause right now.

Perhaps my Macbook is just acting up… I am not able to reproduce it right now!

It wouldn’t be vim, but rather do you use something like elixir-ls with it or what elixir plugin do you use?

This is not what the question was about, this question was about a feature of the phoenixframework which should automatically recompile changed code when the development server is running.

yes and the problem is only with the dependencies and when you specify the path in mix.exs mix will recompie whenever we change something in that dependency.
it happened with me and when i try to recompile iex returned :noop, the process mentioned solved the issue.

You usually do not want to change something in deps.

A better way to do what? As I said already, neither it is idiomatic to change code in deps nor is it necessary.

If you have the feeling you have to edit code in that folder, then you are probably doing things wrong and you should stop. Tell us what you actually want to achieve and we can tell you the proper way to do so.

Which was not about changing phoenix code in the deps, but about code of the actuall application.

I had a situation to change a dependency for my project to work. not phoenix dependency its just an example. i faced the same issue and this worked for me