ndmitchell / ghcid

Very low feature GHCi based IDE
Other
1.13k stars 114 forks source link

Error when waiting, if this happens repeatedly, raise a ghcid bug. user error (could not create file system event stream) #324

Open MaxGabriel opened 4 years ago

MaxGabriel commented 4 years ago

Hi, I'm a happy user of ghcid but today it got stuck in some sort of loop where it was constantly refreshing. It printed this error:

Error when waiting, if this happens repeatedly, raise a ghcid bug. user error (could not create file system event stream)

I stopped ghcid and started again and it happened again. I searched the issues here and saw you requested starting with --verbose when this happens to get the full log output. I've uploaded that here: https://gist.github.com/MaxGabriel/167eadb8548286177ffbea95ca73757d

I committed that code in case I need to reproduce later.

Environment info:

I'm running inside nix-shell on MacOS 10.15.2

 ~/D/M/h/mercury-web-backend> nix-shell --version
nix-shell (Nix) 2.3.2
(130) ❄️  ~/D/M/h/mercury-web-backend> ghcid --version                                                                                                                                                                    21:03:16
Auto reloading GHCi daemon v0.7.6
❄️  ~/D/M/h/mercury-web-backend> ghc --version                                                                                                                                                                            21:05:20
The Glorious Glasgow Haskell Compilation System, version 8.6.5
❄️  ~/D/M/h/mercury-web-backend> cabal --version                                                                                                                                                                          21:05:24
cabal-install version 3.0.0.0
compiled using version 3.0.0.0 of the Cabal library
MaxGabriel commented 4 years ago

I restarted nix-shell and tried ghcid again. I eventually got an error about running out of file descriptors. I'm guessing I need to raise that limit to fix

src/Mercury/Yesod/Routes/Metrics/Instance.hs:5:1: warning: [-Wunused-imports]
    The import of ‘ClassyPrelude’ is redundant
  |
5 | import ClassyPrelude
  | ^^^^^^^^^^^^^^^^^^^^
src/Mercury/Network/Wai/Middleware/HostCheck.hs:4:1: warning: [-Wunused-imports]
    The import of ‘Request(requestHeaders)’
    from module ‘Network.Wai’ is redundant
  |
4 | import Network.Wai (Middleware, requestHeaders, responseBuilder)
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/Mercury/Network/Wai/Middleware/HostCheck.hs:13:1: warning: [-Wunused-imports]
    The import of ‘App’ is redundant
   |
13 | import App (App)
   | ^^^^^^^^^^^^^^^^
src/Mercury/Metrics/Helpers.hs:43:1: warning: [-Wredundant-constraints]
    • Redundant constraints: (Label label, MonadMonitor m)
    • In the type signature for:
           observeLabeledDuration :: forall (m :: * -> *) label metric a.
                                     (MonadIO m, Label label, MonadMonitor m) =>
                                     PVector label metric -> label -> m a -> m a
   |
43 | observeLabeledDuration :: (MonadIO m, Label label, MonadMonitor m) => PVector label metric -> label -> m a -> m a
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
src/Mercury/Metrics/Helpers.hs:44:1: warning: [-Wunused-top-binds]
    Defined but not used: ‘observeLabeledDuration’
   |
44 | observeLabeledDuration pVector label action = do
   | ^^^^^^^^^^^^^^^^^^^^^^
src/Mercury/Metrics/Helpers.hs:44:24: warning: [-Wunused-matches]
    Defined but not used: ‘pVector’
   |
44 | observeLabeledDuration pVector label action = do
   |                        ^^^^^^^
src/Mercury/Metrics/Helpers.hs:44:32: warning: [-Wunused-matches]
    Defined but not used: ‘label’
   |
44 | observeLabeledDuration pVector label action = do
   |                                ^^^^^ghcid: ghcid.txt: openFile: resource exhausted (Too many open files)
make: *** [Makefile:141: ghcid] Error 1
(2) ❄️  ~/D/M/h/mercury-web-backend>                                                                                                                                                                                      21:34:37
ndmitchell commented 4 years ago

Does the instructions at https://github.com/ndmitchell/ghcid#why-do-i-get-addwatch-resource-exhausted-no-space-left-on-device-on-my-mac help? It seems like the error message might have changed, if so, I'll update the FAQ to include both. I did a quick audit of the file reading code in Ghcid, and it looks pretty solid - I can't see any leaks so I suspect it's just Mac having really low defaults.

MaxGabriel commented 4 years ago

I didn't follow those instructions exactly, but I followed similar-ish ones that make it a permanent setting. That appears to have fixed it (caveat that I rebooted to apply those settings, so it's possible the reboot helped in some way).

I agree that it seems like this is just a Mac having low default file limits issue.

I think this is fine to close. I think updating the FAQ sounds good!

ndmitchell commented 4 years ago

Do you have a link to the instructions you followed? If they are better, by virtue of being permanent, then I'll happily replace the FAQ.

kubek2k commented 1 year ago

There is a slight change in most revent Mac OS (Ventura in my particular case). There is no longer an option to set limit of watches. For some reason setting max opened filed limit helps: http://eradman.com/entrproject/limits.html. 🤔