streamly icon indicating copy to clipboard operation
streamly copied to clipboard

Event.watchPaths throws: addToWatch: /some/example.csv/: inappropriate type (Not a directory)

Open Unisay opened this issue 2 years ago • 8 comments

Expected behavior:

As documentation says:

The paths could be files or directories.

Actual behavior:

  filePath <- toUtf8 "/some/example.csv"
  Event.watchPaths (pure filePath)

throws:

addToWatch: /some/example.csv/: inappropriate type (Not a directory)

Unisay avatar Oct 28 '21 15:10 Unisay

@Unisay sorry for the delay in answering this. We missed this issue somehow.

The behavior of fsevents is highly platform specific. Which platform are you seeing this behavior on? We have to test this particular aspect better and correct the documentation if necessary or fix the code.

BTW We have made several changes to the fsevents subsystem recently and also created a common fsevents module that tries to capture the platform independent behavior. We are going to release 0.8.1 soon which will have these changes.

harendra-kumar avatar Nov 23 '21 21:11 harendra-kumar

A file root works on macOS, I added tests for it in the darwin test suite a while ago. There are TODOs for the same in Linux and Windows test suites, let's add those and fix if anything needs to be fixed or documented as part of this issue.

The working darwin tests are here.

For Linux failing tests are here.

For Windows we have a TODO here. Should be easy to copy the tests from darwin test suite.

We need to fix the Linux code and get the Windows tests working.

harendra-kumar avatar Nov 24 '21 10:11 harendra-kumar

@Unisay let me know if you would be in a position to contribute to this.

harendra-kumar avatar Nov 24 '21 10:11 harendra-kumar

Sure, what can I do to help with this issue?

Unisay avatar Nov 24 '21 15:11 Unisay

  1. You can try the master branch and check if it works for you as expected. The non-recursive watch on Linux should work for files as well - see this test.
  2. The recursive mode watch on Linux has some issues with file type watch roots as I mentioned above, if you feel like investigating you can investigate and fix it, and enable the tests.
  3. If you are using Windows then you can add the same tests for Windows and make sure they pass.

harendra-kumar avatar Nov 24 '21 15:11 harendra-kumar

I believe this got fixed in release 0.8.1 which is on hackage now. Watching files works on macOS and Linux but it does not work on Windows, therefore, the docs in the common module/Windows module have removed that statement, but docs for macOS and Linux modules still have it.

@Unisay can you verify if everything is according to the documentation?

harendra-kumar avatar Dec 01 '21 00:12 harendra-kumar

This has only happened once (many other test runs were successful) on Fedora Linux (Github Codespace):

Failures:

  ./Streamly/Test/FileSystem/Event/Common.hs:203:9: 
  1) FileSystem.Event.Linux.recursive, Root type DirType, dir deleted (subdir/dir)
       uncaught exception: ErrorCall
       Time out occurred before event watcher could terminate
       CallStack (from HasCallStack):
         error, called at ./Streamly/Test/FileSystem/Event/Common.hs:203:9 in main:Streamly.Test.FileSystem.Event.Common

  To rerun use: --match "/FileSystem.Event.Linux/recursive/Root type DirType/dir deleted (subdir/dir)/"

Randomized with seed 889562565

Finished in 29.7849 seconds
28 examples, 1 failure

Unisay avatar Dec 02 '21 07:12 Unisay

I guess this is the test that is failing. If you are able to reproduce this, then it would be helpful if you can paste more information from the test output, the events that were generated by the test are printed on the console, from that we can find out which events did not get generated that we were expecting in the test.

harendra-kumar avatar Dec 04 '21 01:12 harendra-kumar