haskell-fswatch / hfsnotify

Unified Haskell interface for basic file system notifications
BSD 3-Clause "New" or "Revised" License
136 stars 40 forks source link

Build failure on FreeBSD #105

Closed arrowd closed 1 year ago

arrowd commented 1 year ago
Building library for fsnotify-0.4.0.0..
[6 of 7] Compiling System.FSNotify  ( src/System/FSNotify.hs, /wrkdirs/usr/ports/devel/stack/work/stack-2.9.1/dist-newstyle/build/x86_64-freebsd/ghc-9.2.4/fsnotify-0.4.0.0/build/System/FSNotify.o, /wrkdirs/usr/ports/devel/stack/work/stack-2.9.1/dist-newstyle/build/x86_64-freebsd/ghc-9.2.4/fsnotify-0.4.0.0/build/System/FSNotify.dyn_o )

src/System/FSNotify.hs:161:28: error:
    * Couldn't match type `Int' with `()'
        arising from a functional dependency between:
          constraint `FileListener NativeManager ()'
            arising from a use of `initSession'
          instance `FileListener PollManager Int' at <no location info>
    * In the first argument of `liftIO', namely `(initSession ())'
      In the first argument of `(>>=)', namely `liftIO (initSession ())'
      In the expression: liftIO (initSession ()) >>= createManager
    |
161 |     WatchModeOS -> liftIO (initSession ()) >>= createManager
    |                            ^^^^^^^^^^^
tachylyte commented 1 year ago

I have exactly the same issue on NetBSD 9.3.

thomasjm commented 1 year ago

Ah yes, I see the problem. There's no native file watcher on BSD so it's trying to treat the polling file watcher as native. Will put out a patch soon.

arrowd commented 1 year ago

FreeBSD has a libinotify-kqueue library, which implements Linux inotify interface using FreeBSD native kqueue. It might have sense to use it for fsnotify?

thomasjm commented 1 year ago

Oh that's cool, I was thinking we'd have to do a kqueue module. Although that might still be a good idea since it would help on Mac too. But in the short term we'll just have this library go back to using polling on BSD.

thomasjm commented 1 year ago

My efforts to get a FreeBSD VM with a Haskell toolchain aren't going so well, could one of you try doing stack build with the latest code on master?

arrowd commented 1 year ago
[6 of 7] Compiling System.FSNotify

/usr/home/arr/projects/hfsnotify/src/System/FSNotify.hs:94:22: error:
    Not in scope: type variable ‘error’
   |                      
94 | type NativeManager = error "No native file watcher is available on this system. Please use WatchModePoll instead."
   |                      ^^^^^

/usr/home/arr/projects/hfsnotify/src/System/FSNotify.hs:94:28: error:
    Illegal type: ‘"No native file watcher is available on this system. Please use WatchModePoll instead."’
      Perhaps you intended to use DataKinds
   |                      
94 | type NativeManager = error "No native file watcher is available on this system. Please use WatchModePoll instead."
   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Completed 116 action(s).  
arrowd commented 1 year ago

My efforts to get a FreeBSD VM with a Haskell toolchain aren't going so well

FreeBSD VM can be easily obtained using Vagrant, and to get Haskell just run pkg install hs-stack.

thomasjm commented 1 year ago

Aha, that works -- thanks!

thomasjm commented 1 year ago

This is not strictly required to fix the bug but could you tell me how to increase the resolution of the console for a FreeBSD Virtualbox guest :)? I had started with an image from here before you mentioned Vagrant. I tried several Google suggestions but it's still like 80 chars.

arrowd commented 1 year ago

It might be not that easy if the image you downloaded doesn't use UEFI, which is probably the case. It might be faster to get an SSH server:

echo PermitRootLogin yes >> /etc/ssh/sshd_config
echo PasswordAuthentication yes >> /etc/ssh/sshd_config
echo PermitEmptyPasswords yes >> /etc/ssh/sshd_config
sysrc sshd_enable=yes
service sshd start
thomasjm commented 1 year ago

Thanks! This should be good to go on master now. Would someone like to try it out before I push to Hackage?

tachylyte commented 1 year ago

Not FreeBSD, but I've just done a cabal build on master on NetBSD 9.3. No problems with the build. Thanks for fixing this!

thomasjm commented 1 year ago

Uploaded to Hackage as 0.4.0.1.

arrowd commented 1 year ago

Yep, also builds on FreeBSD. Thanks for fixing this!