air icon indicating copy to clipboard operation
air copied to clipboard

Windows file changes are not captured when dockerized

Open cywk99 opened this issue 3 years ago • 14 comments

The changes made on windows are reflected inside the docker container via volumes but not capture by Air. Editing the file directly inside the docker will trigger rebuild, changes reflected on windows side also.

cywk99 avatar Aug 31 '21 14:08 cywk99

Got the same issue. When editing files on Windows with Goland which are mounted inside my golang:1.17 container with air installed it does not trigger the rebuild. Any ideas on how to solve this problem?

xEtarusx avatar Sep 07 '21 12:09 xEtarusx

If you are running the docker engine on the WSL2, this behavior is due to the WSL2 limitation. inotify filesystem events are not propagated between WSL2 and Windows. https://github.com/microsoft/WSL/issues/4739

You can avoid inotify problem by environment variable CHOKIDAR_USEPOLLING=true, but it may cause performance problem.

makiuchi-d avatar Sep 11 '21 06:09 makiuchi-d

If you are running the docker engine on the WSL2, this behavior is due to the WSL2 limitation. inotify filesystem events are not propagated between WSL2 and Windows. microsoft/WSL#4739

Thanks, that's the source I think.

You can avoid inotify problem by environment variable CHOKIDAR_USEPOLLING=true, but it may cause performance problem.

CHOKIDAR is for nodejs from what I searched. Any solution for go?

cywk99 avatar Sep 11 '21 08:09 cywk99

ah... sorry, air uses fsnotify, not chokidar. as far as i know, air (and fsnotify) does not implement polling fallback. so it seems that this problem cannot be avoided.

makiuchi-d avatar Sep 11 '21 15:09 makiuchi-d

Can anyone solve this problem ?

CRYBOII avatar Oct 02 '21 19:10 CRYBOII

We are still waiting for WSL solution. Until then:

Put your Project from Windows to \\wsl$ -> {Your Distro} -> /home -> {username} / {[project_path} and NOT in /mnt/c/Users/...

Then Open the first location (\wsl$ from VSCode or editor of your choice). Save will now send the notification of the changed file

NTFS vs linux fs issue

NikosDevPhp avatar Oct 04 '21 18:10 NikosDevPhp

We are still waiting for WSL solution. Until then:

Put your Project from Windows to \\wsl$ -> {Your Distro} -> /home -> {username} / {[project_path} and NOT in /mnt/c/Users/...

Then Open the first location (\wsl$ from VSCode or editor of your choice). Save will now send the notification of the changed file

NTFS vs linux fs issue

I can't find \wsl$

CRYBOII avatar Oct 05 '21 14:10 CRYBOII

We are still waiting for WSL solution. Until then:

Put your Project from Windows to \\wsl$ -> {Your Distro} -> /home -> {username} / {[project_path} and NOT in /mnt/c/Users/...

Then Open the first location (\wsl$ from VSCode or editor of your choice). Save will now send the notification of the changed file

NTFS vs linux fs issue

Thanks for sharing info, I get more details to resolve windows system docker issue. The idea is enable WSL2 in your windows system, and install any Linux system such as Ubuntu.

  1. wsl --set-version Ubuntu 2
  2. Refresh docker setting -> Resouces -> WSL INTEGRATION -> enable Ubuntu
  3. open terminal and type wsl
  4. cp -r /mnt/c/Users/XXXX/projectname ~/
  5. code .
  6. docker-compose up --build

CoolersCoder avatar Dec 22 '21 03:12 CoolersCoder

We are still waiting for WSL solution. Until then: Put your Project from Windows to \\wsl$ -> {Your Distro} -> /home -> {username} / {[project_path} and NOT in /mnt/c/Users/... Then Open the first location (\wsl$ from VSCode or editor of your choice). Save will now send the notification of the changed file NTFS vs linux fs issue

Thanks for sharing info, I get more details to resolve windows system docker issue. The idea is enable WSL2 in your windows system, and install any Linux system such as Ubuntu.

  1. wsl --set-version Ubuntu 2
  2. Refresh docker setting -> Resouces -> WSL INTEGRATION -> enable Ubuntu
  3. open terminal and type wsl
  4. cp -r /mnt/c/Users/XXXX/projectname ~/
  5. code .
  6. docker-compose up --build

Can confirm this works. Thank you!

cywk99 avatar Dec 23 '21 12:12 cywk99

Is this problem solved?

yigeqiji avatar Jun 29 '22 10:06 yigeqiji

Is this problem solved?

No, right now the solution is to move the project into the Linux filesystem in WSL.

See https://github.com/cosmtrek/air/issues/190#issuecomment-999254716

insyri avatar Jun 29 '22 16:06 insyri

Is this problem solved?

No, right now the solution is to move the project into the Linux filesystem in WSL.

See #190 (comment)

thanks,i will take a look,hope this problem can be solved as soon as possible

yigeqiji avatar Jun 30 '22 02:06 yigeqiji

Hi. I got the same issue, too.

Hugo has a fallback polling mechanism implemented. https://github.com/gohugoio/hugo/pull/8723 Could something like this be done here too ?

vkhobor avatar Jul 01 '22 00:07 vkhobor

Hi. I got the same issue, too.

Hugo has a fallback polling mechanism implemented. gohugoio/hugo#8723 Could something like this be done here too ?

Air uses fsnotify, which is a go library for listening to file system events. fsnotify has not implemented a polling fallback feature. The issue (https://github.com/fsnotify/fsnotify/issues/9) has been in discussion since 2014; as of right now, I would recommend using an alternative like stated above until further notice.

insyri avatar Jul 01 '22 00:07 insyri