microsoft / WSL

Issues found on WSL
https://docs.microsoft.com/windows/wsl
MIT License
17.23k stars 808 forks source link

Filesystem watchers like libinotify do not work #216

Closed mablae closed 7 years ago

mablae commented 8 years ago

The whole /proc/sys/fs structure is missing, too.

inotitywait does not get triggered by filesystem changes.

stehufntdev commented 8 years ago

Thanks for reporting the issue.

Currently, only portions of procfs are implemented and there is limited inotify support. To get this on our priority list can you add it to our [UserVoice](https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/category/161892-bash page) page? Thanks again for trying out WSL!

patryk9200 commented 8 years ago

I just added at UserVoice request for filesystem watchers & inotify. https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/13469097-support-for-filesystem-watchers-like-inotify

mablae commented 8 years ago

@patryk9200 Thanks!

JSMike commented 8 years ago

All of the node.js watch functions that I've tried fail on EPERM. I've ensured that all files and directories that it's trying to access have the proper ownership group and user. I even tried running watch tasks as the root user, and I receive the same eperm issue. I've also made sure that all of the files are listed inside the linux subsystem, and that I'm not trying to watch files mounted to /mnt/c/

mablae commented 8 years ago

JSMike: It does not work. This is why we opened this issue :smile:

JSMike commented 8 years ago

yes, I was just trying to add detail

stehufntdev commented 8 years ago

Thanks for the feedback. Inotify will not be fully supported in the Anniversary update, but we are tracking the work for future insider builds. If you haven't already, please vote on the user voice page for inotify (https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/suggestions/13469097-support-for-filesystem-watchers-like-inotify).

alanosman commented 8 years ago

I'm in the same boat #697 .. I have to go back to CygWin until we can see this resolved. I am very excited about this in Windows though. I spent a good day trying to get our dev kit working, and from what I can tell, the build is very solid. But yes, I also fell into missing proc/sys/net problems with mongo too so we will have to come back once these features are enabled.

aseering commented 8 years ago

@SRGOM -- I don't know that there's automated telemetry, but users can vote on issues here:

https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/category/161892-bash

So Microsoft does have some information about both which features people want to use and how much they care about them.

On that note -- have you voted for this issue there? It's relatively high on the list.

ghost commented 8 years ago

Just posting here to show how much I would love to see this feature implemented

jwsloan commented 8 years ago

@meffect if you haven't already, you should throw three votes at it on the UserVoice page linked above. It has gotten a lot of traction lately, but hasn't yet been tagged by the MS team.

catmando commented 8 years ago

how about how to work around the issue in the meantime??? for example what config settings etc, need to be used for a basic rails 5x install?

jwsloan commented 8 years ago

I generated my app with --skip-spring --skip-listen. Then when I run guard I use guard -p to force polling mode. I thought about trying to get spork running instead of spring, but I haven't done that yet. Guard without Spring does make TDD a slow and painful process, though. So I love seeing that UserVoice page getting more votes.

catmando commented 8 years ago

Thanks @jwsloan

If you have already generated a rails app, here is what you have to do to fix:

1) comment out this gems listen, spring, and spring-watcher-listen in the Gemfile:

  #gem 'listen', '~> 3.0.5'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  #gem 'spring'
  #gem 'spring-watcher-listen', '~> 2.0.0'

I am not sure you have to comment out spring / spring-watcher-listen, but that works for me...

Then in the development.rb comment out this line:

  #config.file_watcher = ActiveSupport::EventedFileUpdateChecker

and of course bundle install...

jwsloan commented 8 years ago

Good call on the file_watcher config, @catmando. I forgot about that part. I had to do that as well.

ghost commented 8 years ago

@jwsloan Yep I gave it 3 votes. Imo, it looks more important than some of the ones above it so hopefully microsoft will tag it soon

ghost commented 8 years ago

My currently blocking issue is writing an web application. typescript -watch and gulp -watch no workie. My way around it is to use node/npm windows binaries for gulp and typescript. the work around is ok, but not ideal for me because I use conemu to open 4 bash terminals inside a single window. i dont really like having to open a second window to call windows binaries for various reasons, mainly extra screen real estate needed. Also i'd much prefer to not have those windows binaries installed at all on my machine and just have the linux ones.

But ya there seem to be many other issues out there where you cant really work around them

bluefantail commented 8 years ago

Personally the workaround I used with a rails 5 application was to modify the file_watcher config in development.rb so that it can be disabled with an environment variable.

config.file_watcher = ActiveSupport::EventedFileUpdateChecker unless ENV['NO_INOTIFY']

Then set the the NO_INOTIFY environment variable in my .zshrc. That way one can still easily collaborate with people not using WSL, or just dev on other machines without Gemfile mess :)

I didn't need to do anything with the Gemfile at all here, it seemed to fall back to polling nicely.

jwsloan commented 8 years ago

Thanks for the info, @bluefantail. Are you using Spring with that setup?

bluefantail commented 8 years ago

Yea I am, I initially thought that would be an issue as well and tried re-bundling without it (unsuccessfully). Disabling the file_watcher seemed to do the job, without the need for disabling spring at all. I'm newish to rails, but I can only presume if spring is an issue, the config also disables the spring-listen file watchers as well, or something like that. This is the Gemfile in question https://github.com/bluefantail/bathtub/blob/master/Gemfile

dballance commented 8 years ago

Major blocker for any modern web dev workflow.

awkaiser commented 8 years ago

Voted on UserVoice (glad to see it high on the list there) but, yeah... oof. I was over the moon excited for Bash on Windows until I slammed into this reality. As everyone has said, this impacts a significant slice of modern web development tooling.

:beers: praying for a fix in the near future :beers:

jwsloan commented 8 years ago

@bluefantail: It looks like config.file_watcher = ActiveSupport::FileUpdateChecker may be a better workaround then actually removing the config line. FileUpdateChecker does not cause the same issue as EventedFileUpdateChecker.

That will allow you to be able to run rails server, and you should still get reloaded assets during local development, but it will not help with running rails test. With Spring loaded, that still is causing me issues. TDD becomes very tedious without Spring...

cheshrkat commented 8 years ago

Just a comment noting I've run into the EPERM error with nodejs+grunt-contrib-watch ... it fails so badly you can't even ctrl+c/ctrl+d out, you have to kill WSL entirely.

Like other commenters, it's a blocker to actually using WSL for production level dev. Not trying to be difficult, just indicating the severity/importance. Have voted on user voice as well.

marzubov commented 8 years ago

Hey. I think I might have run into the same problem with EPERM when using Ember.js, which uses NodeWatcher or facebook watchman.

envygeeks commented 8 years ago

/cc BackRef: jekyll/jekyll#5233

seanriceaz commented 8 years ago

I found a workaround for this, which may help you all out.

The issue is that the watch function is using filesystem events that are not currently being exposed to the windows 10 bash shell. Workaround, in short, is to poll for changes instead of listening for events.

For those of you using gulp, you use the gulp-watch package:

var watch       = require('gulp-watch');

gulp.task('sass', function() {
   //Compile my sass
});
gulp.task('serve', ['sass'], function() {
   //Watch for changes and run sass task
   watch("./scss/**/*.scss", {usePolling:true}, function(){
      gulp.start('sass');
    });
});

gulp.task('default', ['serve']);

The gulp watch package is basically a gulp wrapper for chokidar, which you should also be able to use as a replacement for node's watch feature. Pass it the {usePolling:true} parameter and you're golden.

Or if you're running jekyll in ruby, you can just use a flag like so:

#jekyll serve --force_polling

I hope that helps in the meantime while we wait for better support!

envygeeks commented 8 years ago

You mean you found the work around I already mentioned on our tracker?

JasonLinMS commented 8 years ago

We've finished implementing inotify internally, now we just need to wait for it to hit the insider builds. Note that we can only report events that are triggered inside WSL (both DrvFS and VolFs are fine). If you use Windows Notepad++ to make changes, we won't be able to report it.

awkaiser commented 8 years ago

@envygeeks There are a few mentions of falling back to polling in this thread that predate your jekyl/jekyl reference (including an UserVoice comment from August 5th), no need to be rude to contributors. I'm sure somebody will appreciate Sean's particular presentation of the workaround (conveniently inline on this thread).

awkaiser commented 8 years ago

@JasonLinMS Thanks for the update! Is the caveat that changes must occur within WSL permanent, or is there hope for changes made from [insert favorite Windows editor/IDE here] will be picked up?

JasonLinMS commented 8 years ago

@awkaiser Thanks for waiting so long for this! Honestly, implementing inotify for file changes from Windows is a lot more complicated, since WSL can't see those changes, and because Windows vs Linux file operation semantics differ greatly. Unfortunately, the likelihood of this support coming soon is extremely low.

seanriceaz commented 8 years ago

@envygeeks Right, That is the same workaround for Jekyll that you had mentioned earlier (though I had not clicked your backlink until now--apologies).

Regardless, my focus was on a gulp implementation and since I couldn't find a completed solution anywhere else, I figured I'd post what I made here so others in my same situation could save the hour or so of trial and error and have something that works.

ghost commented 8 years ago

@seanriceaz Only issue I have with your post is when you said "I found a workaround for this". This implies you found a workaround for the fundamental cause behind Issue #216 . However that is not true. You are presenting an alternative method of watching the file system for changes when using gulp. This undermines the severity of the fundamental issue and also makes light of other scenarios where gulp can not be used, does not want to be used, or should not be used, in my opinion.

awkaiser commented 8 years ago

@meffect If you're going to split hairs like that, please recognize that "a workaround" is not the same as "the workaround" and "may help" is not the same as "will help." Gulp isn't right for everyone in all cases but it is a very popular tool, and leaving a trail of potentially helpful breadcrumbs for affected developers isn't hurting anyone on this thread. I mean, I don't use Gulp, am not annoyed by Sean's contribution, and feel like it's a bit of a stretch to assert that he's "undermining the severity of the fundamental issue." I'd assume that anyone who has hit a brick wall and discovered this Github Issue while troubleshooting is probably aware of the severity of this issue.

awkaiser commented 8 years ago

@JasonLinMS Bridging the two systems would certainly be a challenge, but good to know it's not completely off the table, just delayed indefinitely until some wizard invents a clever solution. Looking forward to this first step landing.

awkaiser commented 8 years ago

My understanding from what @JasonLinMS is saying is that the upcoming fix will not be able to watch for changes made to files inside your Windows drive mounts (e.g. /mnt/c). If that's the case, and we want to use Windows tools to edit our files, what's the proposed developer workflow?

ericblade commented 8 years ago

@awkaiser from what @JasonLinMS said:

We've finished implementing inotify internally, now we just need to wait for it to hit the insider builds. Note that we can only report events that are triggered inside WSL (both DrvFS and VolFs are fine). If you use Windows Notepad++ to make changes, we won't be able to report it.

you can change files in /mnt/c, but you can't change them using Windows programs. (or at least you won't get a notification)

I'm more curious about this statement, though:

implementing inotify for file changes from Windows is a lot more complicated, since WSL can't see those changes, and because Windows vs Linux file operation semantics differ greatly

So.. if you make a change to something using a Windows app, while the file is open in something in WSL, then WSL cannot see those changes at all? (presumably until all WSL file handles are closed?) Is that how I'm to understand that?

So, there's not a possible way to directly map FindFirstChangeNotification or ReadDirectoryChangesW into inotify ?

awkaiser commented 8 years ago

Thanks for the clarification @ericblade! In terms of developer workflow, doesn't that effectively lead to the same end result: A web developer working in /mnt/c/web/my_cool_project using their favorite Windows editor/IDE won't trigger the watch processes of the aforementioned build tools (Gulp, Browserify, Webpack, etc.) when they save updates to files?

envygeeks commented 8 years ago

That's what I'm assuming because one layer isn't talking to the other and vice verse. However, editing with VIM from the terminal will trigger it I'm assuming.

noinkling commented 8 years ago

If you use Windows Notepad++ to make changes, we won't be able to report it.

That's a bit of a bummer to hear. It's been an annoying problem with using VM shared folders for a long time now (though I believe Macs can make things work using NFS), I was hoping that WSL would finally come along and help us out. I know from experience that polling workarounds (if they're even available) have quite a few downsides. As it stands, workflow, particularly for web dev, is still going to be seriously hampered on Windows machines without some major pain points in terms of configuring tooling... unless you like to work in Vim.

Edit: here is one of the workarounds for Vagrant, readme has a summary of the general problem. Maybe the WSL team can take inspiration.

ericblade commented 8 years ago

I use the Windows versions of most of the stuff that I use, so I'm not especially hampered by this functionality missing, but I did want to see if my operating system builds would work on it, and OpenEmbedded just won't even start up without this functionality. :-)

I'm curious what the behavior is now when you edit a file in a Windows app while you have a handle open in WSL. It seems like having two vastly differing methods of access could potentially cause disturbing results, and I don't just mean you accidentally overwrite some changes you made earlier with changes you just made now, I'm thinking of the catastrophic loss of file type of results. Not that I'm saying it is a thing, but I'd like to know what actually happens, so that we can be aware of it.

onomatopellan commented 8 years ago

Sublimetext for Ubuntu works great inside WSL. Just launch it with an X server like VcXsrv or Xming and it will take advantage of all the new supported features like filesystem watchers.

jwsloan commented 8 years ago

@ericblade, I have seen issues when using Atom on the windows side, and changing git branches in WSL. Things seem to get confused, and I get into a state where neither side has permissions to a certain directory or file. I haven't nailed down the exact reproduction steps, but it has happened more than once, and is quite a pain to recover from.

jwsloan commented 8 years ago

I just noticed @onomatopellan's post. That is brilliant! I know what I'll be doing at lunch today.

laggingreflex commented 8 years ago

[edited after I solved the issue to include the errors and the solutions]

I have vcXsrv running and can run xcalc but when I tried installing sublime text:

sudo add-apt-repository ppa:webupd8team/sublime-text-3
sudo apt-get update
sudo apt-get install sublime-text-installer

it gives this error:

cp: cannot create regular file ‘/usr/share/icons/hicolor/48x48/apps/’: No such file or directory

It does infact installs ok in /opt/sublime_text/, but fails to create links in /usr/local/bin (which, although, can be done manually afterwards with ln -s /opt/sublime_text/sublime_text /usr/local/bin/sublime_text)

But on launching it gives this error:

Unable to load libgdk-x11-2.0.so

It seems I needed to install libgdk and/or xbase-clients and other such basic libraries for GUI support I guess which doesn't come with bare bash.

sudo apt-get install -y xbase-clients libgtk2.0-0 libgdk-pixbuf2.0-0 libfontconfig1 libxrender1 libx11-6 libglib2.0-0  libxft2 libfreetype6 libc6 zlib1g libpng12-0 libstdc++6-4.8-dbg-arm64-cross libgcc1

It might need fewer libs than that but I'm not sure and just being inclusive.

onomatopellan commented 8 years ago

@laggingreflex You shouldn't have problems downloading the tarball: cd sudo apt install libgtk2.0-0 wget https://download.sublimetext.com/sublime_text_3_build_3114_x64.tar.bz2 tar xvjf sublime_text_3_build_3114_x64.tar.bz2 DISPLAY=:0.0 ./sublime_text_3/sublime_text

ericblade commented 8 years ago

@jwsloan

I have seen issues when using Atom on the windows side, and changing git branches in WSL. Things seem to get confused, and I get into a state where neither side has permissions to a certain directory or file.

Yeah.. I'm afraid that actually being able to directly access /mnt/c and such might actually be a really bad idea. Perhaps it might be a good idea to actually yank that file system layer, and replace it with NFS or something. It sounds like it's going to lead people into nasty problems.

cheshrkat commented 8 years ago

though I believe Macs can make things work using NFS - @noinkling

Not sure about NFS, but for anyone who doesn't also use a Mac: yes, on OSX you can go between the CLI and GUI without any serious hitches. Changes can be triggered on both sides, although it remains a bad idea to edit the same file in two different editors (that's just confusing :)).

jwsloan commented 8 years ago

I was able to install submlime-text-3 using the steps that failed for @laggingreflex. Then I used the following so that I can run subl some_file.rb to launch it. ln -s /opt/sublime_text/sublime_text /usr/local/bin/subl