I’m currently trying to work on a LiveView project and have hit a problem with LiveReload not working. I am using an Alpine Docker Image on a Windows 10 machine. Docker is using the WSL2 image with a Ubuntu 20.04 distribution.
When I launch the server I receive a line in my terminal that says
[watch] build finished, watching for changes... and my application connects to the livereload websocket. However from this point on nothing happens when I save a change in any of my files. I don’t see any messages in my terminal saying that a change has been registered or an attempt to send a message down the websocket has been made.
My config looks fine - it’s all generated by Phoenix. A friend using a Linux machine downloaded the repo I am using and LiveReload worked as expected with no changes required on his end.
I have found some old threads here and on SO/Git that suggested there used to be an issue with monitoring files on windows because of different filesystems but these have all been quite old.
Phoenix reloader is using FS under the hood, read and install the required dependencies for your system. As a word of advice, I would avoid using alpine image for development as it is stripped of a lot of functionality.
Thanks for the response. The dockerfile for the image installs
inotify and the readme for Phoenix Live Reload says that installation of
inotify-win isn’t necessary.
I went ahead and installed
inotify-win anyway just in case but it didn’t produce a change in the behaviour of the application. When changing a file on the volume there is still no reaction in either the terminal or the browser.
I suppose since there is no systemd like on a classical ubuntu docker image, you have to start manually the inotify watcher.
Thanks for the advice! I installed Elixir on my base Windows machine and everything in the application works as intended so I know its not an application config issue.
Likewise, a friend has taken the same repo with the docker and docker-compose file on his Linux system and liveload worked without any changes from him. I think this suggests that the environment the docker image creates is OK.
In my windows hosted docker image I did start an inotify watcher manually and when I made a save no event was announced but I don’t hold too much stock in this as its the first time I’ve used the tool!
To me it looks like an issue around files that are being tracked are on a volume on the windows host. Something isn’t emitting or receiving an event where it should between those two systems maybe.
I’ve previously only used Elixir for API based projects that have recompiled themselves when they receive a HTTP request so this has never been an issue before. I might log it as in issue on LiveReload. There was a similar issue years ago that was logged as fixed by an update to the
file_system dependency of LiveReload.