Does LiveReload for Phoenix work on Ubuntu?

I have a POP OS system and Live Reload does not seem to work.
I installed the software in the link below and nothing changed.

https://hexdocs.pm/phoenix/installation.html#inotify-tools-for-linux-users

Thank you!

I don’t have a specifically ubuntu system to test on, but I would assume it should function. It works on my arch machine.

How do you know its not working? What version of Phoenix?

Perhaps check the config is watching the correct dirs, try looking in config/dev.exs for live_reload, do the paths match the disk layout?

Also you could try running inotify manually and checking its functioning correctly (I think try inotifywatch --help in your term).

works for me, 20.04 LTS

I know it’s not working because I’ll remove some html in a view and save the file - and the render doesn’t update.

1.7

It should work, maybe restart your system. I have worked with code reloading from ubuntu 16 and it works even to this day with 22.

If a restart doesn’t work, try running with extensions disabled or try another browser. The problem is most likely with something in your browser. It should work fine.

I tried multiple browsers and restarting my system doesn’t change anything.

I don’t know what any of that means.

The weird thing is I have been working with LiveReload not working but irrespective of the browser not updating, previous, the terminal would update with code changes.

Now, when I make changes the terminal does not update until I refresh the browser.

That’s what live-reload means in Phoenix apps. You don’t have to stop the server, compile the code, then start the server again to make your new code to be effective. After all, Phoenix is a server-side web framework.

Hello, I’d like to tell you some paths to debug this problem.

1. check the path of the file you modified, and make sure the path is specified by the live_reload config.

In 1.7, the default config looks like:

config :hello, HelloWeb.Endpoint,
  live_reload: [
    patterns: [
      ~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
      ~r"lib/hello_web/(controllers|live|components)/.*(ex|heex)$"
    ]
  ]

The live_reload works only when the path matches the patterns.

2. check the message in websocket connection of live_reload.

Open the console of your browser, and find ws://localhost:4000/phoenix/live_reload/socket/websocket?vsn=2.0.0 in Network panel.

Check the message sent and received on this websocket connection. It should have something like:

3. make sure inotifywait exist in your $PATH.

On Linux, the underlying dependency is using FileSystem.Backends.FSInotify. According to the docs, you should make sure inotifywait exist in your $PATH.

1 Like