WSL: [WSL2] File changes made by Windows apps on Windows filesystem don't trigger notifications for Linux apps
WSL2 is really close to being a perfect runtime environment for server apps being developed in Windows. Great job! One missing feature however is breaking a core part of the developer flow.
For sources stored on the Windows filesystem, any changes made by Windows applications such as Visual Studio do not trigger any file change notifications as far as Linux apps are concerned. This means that all “live rebuild”-type tools don’t work (examples: webpack --watch, jekyll --interactive, and Tilt.dev) when running under WSL2. This unfortunately renders many modern dev workflows unviable.
Notes:
- I strongly expect this is already a known issue as hinted here. However I was unable to find any open GitHub issue that specifically tracks this. #1956 is about a different scenario, #4064 isn’t specifically about change notifications, #4224 is closed, #4293 doesn’t fix it.
- I’m aware the WSL team suggests that with WSL2 it’s good to store your application sources inside the Linux filesystem instead of the Windows one. However I don’t think that’s a viable solution since the whole point of WSL (for me) is to be able to use Windows-based editors such as full VS with a Linux dev environment. If it was sufficient to use Linux-based editors, I’d just use Mac/Linux as my actual OS and would have no need for WSL.
- This did work great on WSL1
- Changing
fs.inotify.max_user_watchesdoesn’t affect this, since the issue is about changes originating on the Windows side.
Bug report template
-
Your Windows build number: 10.0.19033.1
-
What you’re doing and what’s happening:
This applies to all tools that listen for file change notifications, but as an example take
webpack. Repro steps:- In your Windows filesystem, create an empty directory (example:
c:\repro), and then add these three files to it - In a WSL2 Ubuntu 18.04 environment, install Node and NPM:
sudo apt-get install nodejs npm - Still in WSL2, go into the directory from earlier:
cd /mnt/c/repro - Restore NPM dependencies:
npm i - Run Webpack in watch mode:
npm run build:watch. Wait a few seconds until it completes the first build. It will now be waiting for further changes to your source files. - In a Windows application (e.g., Notepad or Visual Studio), open
c:\repro\index.jsand save some change to it. For example, change'Hello, world'to'Hello, world 2'.
- In your Windows filesystem, create an empty directory (example:
-
What’s wrong / what should be happening instead:
Expected behavior: Webpack should see the change and rebuild. That is, you’ll see it log information about another build, and the output in
dist/bundle.jswill be updated.Actual behavior: Webpack doesn’t respond at all, because there’s no file change notification.
Finally I understand that the fix for this is likely to be “add file watch capabilities to the Plan9 server”, and you may feel this is already being tracked by #4064. However #4064 describes a more obscure symptom of this missing feature and makes it sound like an intermittent issue. What I’m reporting here is not intermittent at all, and is a pretty mainstream scenario (using tools like webpack --watch). Thanks!
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 629
- Comments: 168 (5 by maintainers)
Links to this issue
Commits related to this issue
- Temporary workaround during dev on Windows -There is no inotify event propagation yet in WSL2 - https://github.com/microsoft/WSL/issues/4739 — committed to whendershot/masahiro_seikotsuin_site by whendershot 4 years ago
- feat(hot-esm): Use polling for Windows 9P file systems - See https://github.com/microsoft/WSL/issues/4739 - inotify currently does not work on 9P file systems [#33] — committed to vinsonchuong/hot-esm by vinsonchuong 4 years ago
- fix: development stage of Dockerfile, add volume mappings for compose now "docker compose up --build" spins up a development build locally, hot reloading on Windows 11 + Docker Desktop didn't work, b... — committed to City-of-Helsinki/palvelutarjotin-ui by karisal-anders 2 years ago
- fix: development stage of Dockerfile, add volume mappings for compose now "docker compose up --build" spins up a development build locally, hot reloading on Windows 11 + Docker Desktop didn't work, b... — committed to City-of-Helsinki/palvelutarjotin-ui by karisal-anders 2 years ago
Is there a temporary fix to this? This is giving me a headache.
Using Windows 10, WSL 2. Running npm run serve on my Vue project, which normally hot reloads when I do changes (on my Linux and Mac, and WSL1 and I think maybe WSL2 before(?)). Now I have to shut down and restart the Vue server.
Will probably just install Linux on this machine. Developing on a Windows machine is a real pain.
@craigloewen-msft Thanks for messaging me back! I actually solved my issue by moving my project to the linux filesystem in WSL and have had no problems so far. I suggest doing the same. In VS Code simply type ctrl-shift-p and then type “Remote-WSL: New Window” This lets users use the linux filesystem in vs code, for those that did not know this 😃
For those stumbling upon, some notes about WSL2 features & limitations (OS build 19041.21, insiders slow ring):
\\wsl$\)localhostis managed for you by Windows, and allows access to WSL2. Some cases require accessing the WSL2 VM by it’s IP directly.Very disappointing that this is still an issue after 3 years.
@nake89 That’s great if your scenario allows it. But just to clarify for anyone else reading, that’s not a solution in general as it doesn’t work for other Windows-based editors such as VS.
Just keeping this thread alive. This is one of those quality-of-life issues that may not seem critical but, when you run into it every day, really detracts from the polish of WSL
Need this so bad…
Why is this issue labelled ‘feature’? This is a bug and it’s known over half a year now! I have my development data on a separate drive, so it won’t be lost if something happens to my windows system. That’s why the suggested temporary fix is impractical to me… It would be nice if it will be fixed ASAP so people can separate environments and their data.
This has been open since 2019 with no official response.
Can someone lock this thread, please? Getting tired of “me too” notifications, and it’s fairly clear the maintainers aren’t going to respond, so you might as well block this noise and just let us know if it ever gets fixed.
Or if you’re not going to address this, maybe just close the thread.
Everyone knows what the problem is, and only MS can solve it - no reason to waste anybody else’s time then.
Honestly, the suggestion to use linux filesystem is killing me. Why? Because the only filesystem you can trust is your real machine filesystem. I manage my folders and files and I know what I’m doing with them. But I don’t manage the volume in WSL2 (I even didn’t create it - it was “magically” created with the system upgrade and activation of WSL2). So, personally, I’m afraid that due to some kind of my ignorance I risk to delete it occasionally. Maybe to some of you it will sound silly/not enough persuasive, but for me switching to this way of workflow is almost not anyhow different from running just a virtual machine with a mounted folder. With the slight bonus for a VM due to the fact that I do there everything explicitly.
This should be a huge warning before allowing any upgrade. A lot of effort to migrate to WSL2 and now I have to make my way back. So much time was lost trying to understand what was happening for no reason.
You can’t call “don’t use X feature” a workaround for an issue titled “feature X does not work”.
The issue is “File changes made by Windows apps on Windows filesystem don’t trigger notifications for Linux apps”. Therefore, “don’t use Windows filesystem, use the Linux one”, does not seem an acceptable workaround for this particular issue (even if it actually works, as much as installing a full ubuntu, running a rapsberry or riding a bike)
Umm click unsubscribe? Me too comments demonstrate how widespread the issue is and allow for discussion around workarounds/root cause. If you’re not interested, simply unsubscribe.
@hariadiarief @laudukang @gsarig @BenMorel @rodrigogs
I can confirm it finally works on WSL2! 🎉 Just moved my Next.js (React) project from
/mnt/d(Windows 10 D:/ drive) to\\wsl$directory and reloading is working. Moreover - everything is pretty damn fast . It’s like on native Windows with this difference that now we have all ubuntu’s juice 💪Small tip for windows users:
D:\projects\my-appthat was accessbile in WSL ubuntu via/mnt/d/projects/my-app\\wsl$\Ubuntu\home\USER_NAME\projects\my-appAnd don’t forget to open project in vscode using remote-WSL mode:
This info should be pinned on every Docs that mention about developing on Windows under WSL.
I’m really glad I found this gh issue. I was trying to fix this problem for days and was pulling hairs from my head to just give up and leave WSL. Now that’s awesome dev experience 😃
@OneBlue @craigloewen-msft HELLO? Fix this.
Is there a timeline for when this is going to be implemented/fixed? I make heavy use of OneDrive with all my scientific projects/code files hosted there . It’s not really feasible for me to break up my directory structure and start putting files in WSL2.
When it will be fixed? I can’t use Sublime 4 (file tree doesnt update)
A workaround for anyone using Webpack or other tool that uses Chokidar under the hood; you can set an environment variable to use polling instead of listening for file events.
I use this with Docker by putting it in a
.envfile that Docker Compose picks up when it starts. However, you should be able to prepend any start commands with this env as well.This isn’t a great solution since it dramatically increases the resources the OS or Docker needs to consume in order to perform the polling and it will drain your laptop batteries way faster than actual file system event watching, but it works until WSL2 triggers those file system events.
Geez, 4 years, still no solution? This bug breaks so many things. How do we escalate it to MS to have a look?
Lol . I did move on to pure Ubuntu
Ditto. This is a big problem, if anyone doesn’t want to hear, they should unsubscribe!
Just to add my two cents; while I do agree that it would still be too slow for many users, getting back into that range of being some 10x faster would probably be ‘enough’ for most of us. It wasn’t a problem I personally had with WSL1, but it is a very real problem with WSL2 unfortunately. I’m able to move some of my projects over to the wsl side but not all of them, two reasons for this are:
It may be worth providing an official update over in #4197 since it’s been over a year since the last update, and the discussion has gotten very fragmented with that issue locked. Or maybe just a meta discussion issue for these various WSL1 -> WSL2 filesystem regressions?
No kidding genius. WSL is a joke and so is this project.
I just adding my comment that I have also this problem and it means that I can’t use Docker for developing my web app 😦
My solution to have everything work seamlessly is to downgrade to WSL1.
Do Not Upgrade to WSL2.
Going back to WSL1 ? Open a PowerShell :
Even if your favorite program advocate for it (like Vscode who tell you WSL2 have better performance), there’s so many pitfall that it’s not worth doing it.
File system is broken, you can’t work in /mnt/c or /c/, you have to put all of your workflow into the Linux File System (that mean you can’t access it with Windows app like GitKraken). And nothing seem to evolve.
Edit : I don’t want to be to critic because I really like WSL, it’s a game changer project. It’s not bad to wait things stabilized before upgrading to WSL2. Homewever, I revert what I said about the /home/ directory, it seem it’s a best practice to put your files here for better performance and file system seem to work fine. You can still access your files on Windows app with “\wsl$” path, it’s a network file system. But anyway, mixing file systems is always a complicated issue. I hope this issue will get more traction in 2021 👍 .
https://devblogs.microsoft.com/commandline/wsl-2-is-now-available-in-windows-insiders/
@shyce this isn’t how you should ask for help. This is an open source project, the maintainers likely don’t do this as their main job and you’re not paying them anything to fix it. If you want something done, feel free to create a fork and resolve the issue yourself. Otherwise, be patient with the maintainers, they’re aware of the issue and they’ll address it when they can.
“[WSL2] File changes made by Windows apps on Windows filesystem don’t trigger notifications for Linux apps #4739”
Is there a fix for this anywhere in our future? If you’re never going to fix this, then say so!
Any update or workaround for this? Looking to use https://github.com/cosmtrek/air for some docker containers with the code in windows but docker running WSL2 backend. No file updates from windows and therefore air is not hot reloading…
I would also like to chime in that this is a problem that breaks the workflow of tools which trigger a hot reload when files change.
So any news about this bug fixing? It’s very annoying moving the code to linux filesystem to properly develop…
Following. Gotta go back to WSL 1 for now.
Same here, just want to keep my files together in Windows land and host (dev) it using Linux tooling. This always worked great with WSL and Docker for Windows Hyper-V. However, with WSL2 this does not work anymore…
I do not want to move my files to the Linux root system as I have a backup solution that synchronizes my whole User folder and everything under that. If I move some “important” files to the Linux file system I have to keep track of this and back those files up as well.
So for me, moving the files to Linux is not a solution and I would really like to have it work like WSL1 (inotify events from Windows -> Linux).
Why? The project wasted my time. I’m ok with pinging a couple people and getting mad from time to time. That’s life. I’m cooled off but this project still sucks. The internet doesn’t have to always be rainbows and happiness.
Discussing workarounds for the bug is the only relevant use for this topic, so that people who are affected can find a working solution for their use case. Especially when it is clear that we may have to wait decade or two until Microsoft actually fixes the bug itself.
Is this ever going to get fixed? If not, you should at least close it as wontfix so that people can move on with their lives (probably to Linux).
For me, the use use case I look for is to be able to have a file open in a Windows app (usually an editor) and as that file is updated (often by tooling) on the Linux side, I 'd like to see that in the Windows app (without manually going there and refreshing the window / rescanning the directory).
It holds for MS file explorer as well, I’d like it to show accurate file sizes and file dates, when I browse files that are located on the Linux side.
A particular use case I had was developing Ruby Sketchup extensions. Now, Sketchup can only run in Windows environments, so my plugin code needs to be available on that system. However, the tooling I use (to edit, to generate the Ruby code), I prefer to run in a good Linux environment. I was not able to set that up in a straight forward way (I ended up with something like a deploy, from Linux to Windows).
I don’t expect “stellar file system performance” in these scenarios. It’s more about seeing changes done to a handful of files (on the Linux side) being accurately reflected on the Windows side, within a second or two.
I think i’ve got a workaround too, which lets you use it with any editor.
~/projectsfor example)cdinto the project directory and runexplorer.exe .– it will open the current WSL folder on windows explorer. As far as I could see, it just mounts the fs as a network device, so it should be safe as it does not seem to bypass anything.The only thing you loose is the ability to use some stuff, like GitHub Desktop (I could not get it to work, but git cli is fine too). Other than that, it’s been pretty smooth.
Glad that I found this issue. Have been having hell of a time trying to understand what was going on with my new 2004 update / WSL 2 setup and my Hugo site. I must say not having reload while developing has been a great interruption to my workflow 😂.
All we’re asking here is to not be toxic, and act professionally. There are other platforms that suit your need to vent out, but this isn’t the right one.
If you choose to continue that behaviour, then suit yourself. Good luck with your life.
That works but it defeats interoperability. Didn’t they say that WSL is interoperable with Windows?
I’m curious, did anybody ever addressed this to MS engineers directly? Are they aware of that?
Perhaps, not fixing it is a subtle message from Microsoft that we all should move to Linux proper … ? If we did, this problem would certainly be resolved. 🤔
BUILD TIME Comparism with Maven, Java + Docker when people tell me that WSL2 is faster when build from the linux subsystem… well these numbers don’t lie
- Powershell default setup (second time)
- WSL2: Started build in WSL2 didn’t move the data /mnt/c (first time)
- WSL2: did a fresh git-clone in /home/git (first time)
- WSL2: did a fresh git-clone in /home/git (second time)
- WSL2: fit-clone in /home/git & also clean maven artifacts in /home/.m2
So all compared WSL2 is still almost 2x slower than build directly from Windows ==> Hence this BUG should get more priority I’m not even counting the extra time with the Remote VSCode and terminal time you loose initially connection and starting the WSL2.
Well, tried all manner of things to get this working under Windows + WSL 2… still cant. Followed this blog post too: https://www.forevolve.com/en/articles/2020/02/04/speed-up-your-builds-and-watch-for-changes-to-up-to-375-percent-using-this-workaround-on-wsl2-ubuntu/
I tried hosting original project in Windows file system, and Ubuntu file system. I’ve tried starting VSCode from both Windows and WSL. Have tried VSCode in Remote-WSL mode, and regular. I’ve tried running my server from both WSL Terminal, as well as the VSCode built-in Terminal.
None of that is working/getting file changed events. Wtf Windows. Back to Ubuntu native. Grumble.
Has MS committed to making this change? I’m considering going back to WSL1 as it was working quite well. In the WSL1 to WSL2 comparison MS states:
https://docs.microsoft.com/en-us/windows/wsl/compare-versions
“We recommend against working across operating systems with your files, unless you have a specific reason for doing so. For the fastest performance speed, store your files in the WSL file system if you are working in a Linux command line (Ubuntu, OpenSUSE, etc). If your working in a Windows command line (PowerShell, Command Prompt), store your files in the Windows file system.”
also:
"We recommend that you use WSL 2 as it offers faster performance and 100% system call compatibility. However, there are a few specific scenarios where you might prefer using WSL 1. Consider using WSL 1 if:
Your project files must be stored in the Windows file system. WSL 1 offers faster access to files mounted from Windows. If you will be using your WSL Linux distribution to access project files on the Windows file system, and these files cannot be stored on the Linux file system, you will achieve faster performance across the OS files systems by using WSL 1. A project which requires cross-compilation using both Windows and Linux tools on the same files. File performance across the Windows and Linux operating systems is faster in WSL 1 than WSL 2, so if you are using Windows applications to access Linux files, you will currently achieve faster performance with WSL 1."
Maybe it’s not critical, but for me, at least, it’s the reason I’m still stuck with the old WSL.
More simply, I solved by migrating to Ubuntu desktop without Windows at all. Pros: much faster file system and better virtualization using KVM which allows me to virtualizing any peripheral (GPU included).
The workaround I used that I used was to revert to polling instead of depending on inotify. Not ideal for me too, though. Regardless, the point being is that you should try to step back and cool off first, before you throw toxicity here. A better approach would have been to act with more maturity.
@WaldemarH maybe it’s better to delete your not-so-relevant comments on this bug? This is a bug report about WSL2 file system change notifications, not a samba tutorial.
I ended up doing this as well. It’s kinda awkward at first, but it’s the path of least resistance and it works great once you get used to it. If you don’t want to setup
.gitconfigagain, just include it in/home/{your Linux user here}/.gitconfiglike so.Also having this issue, whish it gets fixed but 2 years without progress make me doubt it…
This paints me into a corner where I have to keep my app on an older version of Parcel that (optionally) uses a polling-based approach to detect file changes. The older version lets me edit files in VS Code on Windows, and the changes get picked up in a running docker container (on WSL2). The detection isn’t awesome or quick, but it works. My bigger concern is that I’m stuck with old versions of libraries that aren’t being maintained anymore.
Is this being worked on? This issue renders many dev environments (and thus WSL as a whole) mostly useless for me and undoubtedly others.
The solution of prepending
CHOKIDAR_USEPOLLING=trueto the pertinent command doesn’t work in the case of more complex applications, such as running VS Code.@mindplay-dk WSL overall is targeted towards developer audiences, GUI app support in WSL is targeted towards allowing developers to use Linux GUI apps on Windows.
The feedback in this thread is super valuable to us. I understand that many folks can’t move their files over to the Linux file system, and it’s helpful for us to see the exact whys listed above. As @jasonswearingen detailed there are some great workflows now for projects living in the Linux file system (VS Code Remote, and now GUI apps allows you to access these projects more easily). I’ll make sure to keep this thread updated with any news here, thank you!
If you use VSCode, this workaround may be useful: I have switched to container based development. So, all your work files are located on the container, not on the windows “native” partition. The key which made this workaround useful for me is that you can still access the container source files via windows explorer as a psudo-network share. I can still use SourceTree (a windows, GUI based git client) by passing it the git repo location. Having a gui based git-client was the main reason I wanted my source files on the windows file system, so this workaround effectively solves everything for me.
If you want to access your docker containers files (mounted partitions) from windows, it is located at something like:
\\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes\vsc-remote-containers\_dataThis location is very poorly documented and a lot of false information floating around at places like stack overflow. only by luck did I stumble on it.I hope that helps you out too! Again, This is useful if you need to access the ‘source’ filesystem from windows while needing fast+fs notify support. You do need to watch out for filesystem permissions though, as in my case, my first attempt resulted in a slightly corrupt git folder because permissions defaulted to ROOT/ROOT. After I ensured the folder permissions include the linux user’s user/group and re-downloaded the repository everything worked fine (and no git corruption has occured)
Edit: a big bonus side effect is that with vscode, the linux container’s definition is now included in the git repository under a
.devcontainerfolder, ensuring that the entire dev stack is now reproducable using the git repo as the single source.This. I don’t understand why we have to pick between decent file-system performance under Linux, or a normal, practical, functioning everyday life with Windows. These shouldn’t be mutually exclusive options.
If the file-system performance in Windows isn’t up to the task, really what they should be doing is improve the native Windows file-system performance - which would surely be a win, not just for Linux usage.
If the file-system facilities in Windows can’t handle the Linux permission data, maybe it’s time to enhance the file-system with better meta-data capabilities.
If the file-systems are too different to integrate, maybe it’s time to add support for native Linux file-systems in Windows.
And so on.
Having to use a virtual disk seems like a tedious workaround - I’m really hoping we’ll someday soon see real improvements to the underlying technology, instead of these half measures. Four years on and WSL remains this “would-be awesome” feature that seems to always be “almost there”, but never quite gets there.
Damnit, Microsoft, we’re ready - now take us there, please! 🙏
bump
While I am having similar issue with my React App and I am looking for a solution to this as well, I can reply to:
This hint by @myuseringithub:
is a great one to help you! Also I found out yesterday that since
\\wsl$\is a network resource in Windows you can easily map it to a drive. Then in ANY editor/tool you can use it as if it was on your computer. Just go to the Explorer and manually enter this address to access the resource. You will most likely see “Ubuntu” folder. It is a root of your WSL and it can be mapped to the drive (right click -> map to drive). That helped me setup my project on WSL natively, while being able to edit in the windows editor.Though now I am struggling with Docker containers permissions, which I hope to solve separately and see if reloads in my app work.
Hope that helps.
I wrote a small blog post explaining this workaround and talking about a few more things that I discovered/experienced, using Jekyll on WSL2: Speed up your builds to up to 375% and watch for changes for an even faster dev cycle using this workaround on WSL2/Ubuntu, if that can help someone.
Note: that applies to more than just Jekyll, Jekyll it was just the catalyst.
Yes, #4064 is most unfortunately titled. Worse, the OP has no repro steps and an unecessary symlink confusing the direction they are talking about. Craig’s
notepad.exerepro withcatisn’t aninotify(7)(file watcher) problem, even if implementinginotifyis the fix to whatever loosly implied sync problems are going on over there.Nevertheless #4701 got closed as a dupe with (quoth):
So, best I can tell, #4064 is being treated as the LZ for
inotifytriggers from Windows to WSL2. For lack. #4169 is pretty much exactly your use-case also landed dupe #4064.Yes, known regress.
I think, maybe, accepting that this issue is a giant headache and that frustrated people could do with a little grace? All the chiding is just making this worse, and, dare I say, adding the wrong kind of nutritional content to this thread:
I suffered through the same problem with a recent project, and just decided to use a workaround to resolve it. I also spent a couple of hours fixing my problem only to find out it’s a WSL issue. But, that shouldn’t mean you can always throw your toxicity towards others.
In the meantime I found a workaround using the
intervalparameter set to1000(1 second). The default is 100 and bombards the PC with requests. It’s now down to 15% CPU usage on my 8th gen i7 machine.Vite:
It’s now a lot faster, but it’s also just a workaround, not a fix. Hope to see this fixed someday.
I tried to work around this by setting up a windows file share and mounting with cifs-utils. I was able to mount it however there seems to be some strange bug with running windows executables from the wsl command line within a folder on the mount. If I run ping.exe outside of the mount subfolder it works. Inside a subfolder within the mount I get the following cryptic output:
/mnt/c/windows/system32/ping.exe: Invalid argument. Here is the mount command I am usingmount -t cifs -o username=linux_user,password='pass',vers=3.0 //192.168.0.100/code_linux /mnt/smb/code. The only clue I have is that the issue only happens when you are at least 1 folder deep inside the mount. At the root of the mount, windows executables work fine.If I can resolve this execution issue, I think SMB would be a decent workaround until inotify gets fixed…
PS The reason /mnt/c fix is important, is that storing files on linux is risky since WSL distros have a tendency to spontaneously lose all user files. It also means files can persist across distro changes etc…
This issue persists. Is there a timeline for when it will be resolved?
What is the status of this issue?
This issue might be the reason, why remote development in VSCode does not work well on Windows. All tools that rely on the state of the file, like CMake, or the Git extension need manual refresh each time a file has changed. That’s extremely annoying.
Will this problem be tackled?
Thanks 😃
The issue can be avoided by not mixing file systems, e.g. NTFS with Linux file system until a permanent fix is available by Microsoft for WSL2.
To help others saving time and pain, I wrote up my findings in an article. In it I also describe how I resolved the issue for the combination of VSCode, WSL2 and a Linux-based dev container for .NET. Here is the link: https://levelup.gitconnected.com/docker-desktop-on-wsl2-the-problem-with-mixing-file-systems-a8b5dcd79b22?sk=53d24e33a9f247fd626e3aa6959de7d4
I use my regular Git client in Windows, because my project is still on my Windows machine. However, to get livereload working, I simply add a symlink from my WSL2 home directory to the project on my windows machine, f.e.:
After that, I start
jekyll serve --livereloadfrom~/create-your-future-websiteand open that folder in VS code using ctrl-shift-p and then type “Remote-WSL: New Window” as explained above.This way, you don’t have to move your project and can still enjoy your favorite git client in Windows. Profit!
This is a great workaround that will save me lots of time until WSL2 supports this use-case. Thanks for sharing!
Issue still occurs, I fixed it by moving all files to Ubuntu WSL and running VSCode in Ubuntu (not docker) WSL. I used monorepo with nextjs and docker compose
Hi folks, temporarily locking this thread for now. As a reminder this project follows the Microsoft code of conduct. We’re still tracking this as a known issue, and if you’re experiencing this you can see some of the alternative solutions in the thread above to help it, such as using VS Code Remote, using
\\wsl.localhost\to access the files from the Linux file system, etc.Thank you!
The company is a joke and so are you for defending this lack of effort of a project with some professional facade.
Professional is responding to your github threads that people care about, not ignoring people for 6 years. Professional went out the door years ago when Microsoft started positioning themselves in the linux ecosystem with zero effort and calling their platform a developer environment.
Yeah, wasting 6 hours of my time to try and make Windows a pleasant development experience for anything linux related makes me want to act very polite after 6 years of this many people waiting for a good experience.
You’re SO right. I’m sorry. I’ll change my life for you.
If you think acting politely or with respect equates to always being rainbows and happiness, then good luck with your life, iho.
This is still an issue.
I have to use
usePolling: truewith vite to get it working, but this eats 60% of my CPU and just makes everything sluggish.Will this ever be solved? We aren’t talking about a solo maintainer here, but Microsoft.
@WaldemarH Yeah… would suggest just summarizing it a bit as you did, as an alternative solution, and then maybe linking to a gist with full instructions. Doesn’t hurt and someone else may find it useful for sure. AFAIK it’s one of the only ways to actually link them via network operations.
@MiikaH sorry, this is totally irrelevant. Could we please stay on topic and focus on the bug in WSL? (this message does not require a response)
It’s annoying that this still isn’t fixed and the fact there is no communication from the team is pretty bad.
What seemed to work for me was creating a devcontainer and then using the
Clone Respository in Container Volume...function in vscode with the devcontainers extension. Makes git run much faster, plus you don’t have to worry about setting up your environment in WSL etc.Devcontainers are relatively easy to setup, you just need WSL and Docker installed. The vscode extension for devcontainers can help you create a devcontainer configuration file really quickly.
Not sure if this has been said before, but hopefully it helps someone.
Try prefixing your WSL2 command invocations with the following environment variable, if the commands need to subscribe to filesystem I/O notifications:
@kMeillet and @mindplay-dk that’s some overall great feedback! I agree completely, one of the biggest challenges for any user upgrading to WSL 2 is the fact that they will have to put their projects into the Linux file system to gain the performance advantages. On the team we’re investigating ways to improve this experience (and always open for different ideas!). One of the major factors here is that currently the maximum speed we could theoretically make WSL 2 run on the /mnt/c/ file system is the same speeds as WSL 1, which is still too slow for many users. Overall I believe this speaks to the points in this thread, and we are looking into plans here that are going to a be a mixture of long term and short term improvements.
Some of us have reasons for not moving everything into the Linux filesystem. For anyone else with that problem, my workaround was to create an empty file in the container and include it in the list of files being watched by nodemon. There are several extensions available that run a script on file save, so I installed one and have it touch the empty file any time any of the watched files gets updated.
I think for a temporary solution, you can move your repo/project to the inside WSL 2 directory.
For me it’s solved the problem
@vielhuber I wrote it as a comment for myself, tried to implement it once without success. Just wait till WSL2 will support inotify. You could still use graphical interfaces for git, only that you would have to constantly refresh to see changes, which is the same case when dealing with VSCode’s git panel.
But if you wish to dig deeper, check out:
Get-Content -Waitjust uses a blocking read and doesn’t rely on filesystem events.Any chance we could get a Microsoft person to give us a current status update? It’s hard to tell with this being such a long thread. Might also be worth editing the topmost post (if that’s possible?) so that folks can easily see the current status.
Well, I see that there is no point in furthering this conversation, despite me asking you numerous times to not put your toxicity here. Good luck with your life then, iho.
And what’s the suggestion after 5 years? Go back to WSL1… give me a break. If you can’t do something as simple as notifications after putting the entire kernel in your operating system… it’s lazy. People get paid to make this stuff.
Whatever, I’m hiding this repository and never looking back.
I’m pissed that I wasted 6 hours trying to get this working only to find a 5 year old github thread for such an obvious wall for developers.
If Microsoft took 1 hour to sit down and actually use their products with containers, they would realize it sucks.
Not sure what you mean by that.
You keep your projects in WSL file system, access them via
\\wsl.localhost\. Explorer access, editor & IDE access, docker and everything should pretty much work the same way as if you stored your project onC:\,D:\etc, but now the files are on Linux ext4 filesystem so performance should be way higher than NTFS and file system notifications work as expected, as stated above.And if you want to take things one step further you can (on top of WSL) setup your project to use VSCode “Dev Containers” in order to run the project & VSCode in virtual Linux distro of your choosing. Which not only makes it easier to run Linux primary projects on Windows as you can just run the linux commands natively for the project, improves WSL disk compatibility when the whole setup is doing native linux filesystem calls, and it also separates project dependencies of you main system. As in you can run whichever version of Node.js, Python for each project dev container without any conflicts with versions installed on your host OS. That way if project x recommends Debian, Python 3.10, Cmake 3.8 or whatever - no problem, just configure your devcontainer with those dependencies and you are good to go.
Can you run your project inside WSL? That fixes issues like this for me. If you need access from Windows just use
\\wsl$in explorer/files.If only that was an option, my company is working on Windows exclusively and my coworkers are more likely to pull their own teeth out before switching off of Windows.
Is there really no progress for this issue still?
I came here because VS Code would not automatically refresh source control upon file changes since I have all my project files stored in the windows filesystem - specifically, so I can have them backed up via OneDrive.
I found a solution where you can store your project files on the Linux filesystem and then regularly sync them to your windows filesystem OneDrive folder so that they get backed up. See this blog post from Stephen Rees-Carter for details on how to set it up.
(fyi I deleted the mysql database backup part of the script he provides - I just used it to sync files to a folder in my OneDrive and used Task Scheduler to have it run daily)
Not perfect and takes an hour or two to set up the first time, but after that you don’t need to worry about it and it seems to work quite well so far.
Dang - Still no movement? Unfortunate.
You get the notifications in Linux that way. The other way round could be problematic. I think the question is where the notifications and native speeds have to be available. Windows? Use window FS. Linux or docker based devcontainers? Use Linux FS which can initially be accessed via the network share to clone the code etc.
Nevertheless, this issue should be fixed. I’m not saying there is none.
@jankap the problem here is not the speed but getting the file system changes notification from an app runing under linux.
Thx for sharing. I will check this out
Thanks for sharing this, @jasonswearingen
Same here… I was looking forward to try WSL2 and when I installed it I bumped into this issue, so at least for now, I reverted back to WSL1.
@Carl-Hugo Does that work for you, as in, are changed detected? I’ve been using the \wsl$ path with windows editors for a while because with WSL2 the Linux FS is so much faster, but even when using windows editors with files stored there it’s not triggering HMR when using npm watch.
Is there anything that app devs can do to workaround this in their apps? e.g., is there a different file-change notification API that would work on WSL2 across filesystems? (there are a lot of different file-change notification APIs). Or should we wait patiently for inotify support?