-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sometimes the built file will be empty after live reload. #67
Comments
Maybe you can take a try, the project ispublic, here the repository: honeycomb-adventure . Hoped this information can make some help. |
Thank you @zhengxiaoyao0716! It seems this issue is specific to Windows. Since we can't properly use symlinks on Windows, we need to copy the files and something is happening when we copy them. Pinging @OvermindDL1 in case he has any ideas what may be happening. |
Well, I'm glad that I could help you. Since this problem may caused by |
This is precisely the problem. If you enable symlinks for your user in windows (or run phoenix as administrator) then it works fine. I did a lot of research on that when I had the issue last year, it's documented around here somewhere, but that is the way to solve it on Windows... ^.^; The issue is that Windows doesn't quite flush and unlock the file and phoenix is too fast to acquire the new files, this becomes especially larger of a problem if you use any virus program at all as their file listen hook slows down file access as well since Windows does not have a well made COW or well-journaled file system. |
I thought a message was added at load time that warned you exactly of this and how to fix it as well, wasn't it? |
:D In all seriousness I don't think we can help this one on our end, but maybe we can include docs somewhere for windows to recommend running as admin? |
Lol, more that the beam is too fast because it does not listen for the windows event that says a flush is complete, and even then if an anti-virus exists then it will lock the file before it could be re-opened anyway, thus still causing the same issue... ^.^;
I thought it was already documented when a person loads a phoenix server in dev mode on windows, it should print a good sized paragraph talking about exactly this issue and what to do to work around it. I know I last saw it when I last ran the server on windows (thankfully I finally convinced my job to migrate the servers fully to linux, red hat but eh). |
ah, beautiful. Thanks! |
@OvermindDL1 Thanks, I found the message, it is just in the third screenshots of the first floor, but I didn't realize it at first that this was the reason of this problem. |
@OvermindDL1 As the message guide, I tried to run phx.server as |
I have a small idea, the only thing we need is to create some symbol links as |
Umm, perhaps we have a easier choise, just change the message like |
Hmm, a check to see if the symlink already exists and points to the correct location might indeed be a good quality-of-life workaround, and only be a line or two of code to implement (if the BEAM has a command to query that information, I'm not actually sure, never used it...). You should PR it? :-) |
Also, heh, it is, I missed it too. I could have sworn it was red when I had it back on Windows. |
@OvermindDL1 That is my PR , I tested those code on my windows system locally and they works well, but maybe we need more test on other systems. In addition, I tried some terminals I can found on my Win10, powershell, cmd, mingw. But none of them can render color with [warn] logger. In my VSCode debug console, the message starts with |
For note, none of what you listed are terminals but rather are shells. The terminal you were probably using was 'command' (which is pretty horrible, and even Win10 is trying to phase it out). I tend to use conemu as the terminal myself though. |
I wrote some codes, they were built succeeded and output into
![image](https://user-images.githubusercontent.com/12682063/33940271-4d14cebc-e049-11e7-97d2-50566bbdd0f7.png)
./priv/static/script/
:But, if I change my codes and trigger the
![image](https://user-images.githubusercontent.com/12682063/33940327-809784dc-e049-11e7-9346-6ce570470f3e.png)
live-hot
, sometimes the copied file in_build/dev/lib/my_app_path/priv/static/
would be cleared:This doesn't happened every times, but I think it maybe due to the size of the file was too large and this plugin reload the file early.
I took a try, every time I clear the terminal manual and trigger reload, then record if the file in
_build
directory was cleared:First, start the server, the file was correctly and page looks well:
![image](https://user-images.githubusercontent.com/12682063/33940701-02c2bc6e-e04b-11e7-8bde-5d081d4ee9ff.png)
Clear the terminal and trigger a reload:
![image](https://user-images.githubusercontent.com/12682063/33940742-29c927e4-e04b-11e7-9f2d-c475250765ea.png)
Repeat last step sometimes until the problem happend:
![image](https://user-images.githubusercontent.com/12682063/33940813-73ffe942-e04b-11e7-9a31-62d0d47ab1a4.png)
After compared those too case, we can see the different, while the logger looks like those, everything works well:
![image](https://user-images.githubusercontent.com/12682063/33940910-c7a54fc4-e04b-11e7-8179-97bee8a02cdd.png)
And if the log looks like those, the finally built file would be cleared:
![image](https://user-images.githubusercontent.com/12682063/33940938-e7b3d4ca-e04b-11e7-9e5f-e1421463fa06.png)
I hope that this problem could be fixed as soon as possible, it really interfere my work, thank you.
The text was updated successfully, but these errors were encountered: