zed icon indicating copy to clipboard operation
zed copied to clipboard

[linux] fs: Too many open files

Open williamdes opened this issue 1 year ago • 3 comments

Check for existing issues

  • [X] Completed

Describe the bug / provide steps to reproduce it

As I was editing the setting file_scan_exclusions, it crashed multiple times. It should not and continue to operate.

Thread "" panicked with "Could not start file watcher: Error { kind: Io(Os { code: 24, kind: Uncategorized, message: "Too many open files" }), paths: [] }" at crates/fs/src/fs.rs:423:10

Environment

Zed: v1.0.0 (Zed Dev 3e6a9f68907154009f6741bb8a2ec037c00b7bd8) OS: Linux 1.0.0 Memory: 62.4 GiB Architecture: x86_64

If applicable, add mockups / screenshots to help explain present your vision of the feature

No response

If applicable, attach your ~/Library/Logs/Zed/Zed.log file to this issue.

No response

williamdes avatar Apr 09 '24 08:04 williamdes

When I save the setting value, it seems to process the tree and hide some files and crash. All in ~1sec

williamdes avatar Apr 09 '24 08:04 williamdes

On my side, this bug occurs every time I load a folder. The stack trace:

Thread "main" panicked with "Could not start file watcher: Error { kind: Io(Os { code: 24, kind: Uncategorized, message: \"Too many open files\" }), paths: [] }" at crates/fs/src/fs.rs:454:10
   0: Zed::reliability::init_panic_hook::{closure#0}
             at crates/zed/src/reliability.rs:83:29
   1: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/alloc/src/boxed.rs:2029:9
      std::panicking::rust_panic_with_hook
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:785:13
   2: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:659:13
   3: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/sys_common/backtrace.rs:171:18
   4: rust_begin_unwind
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:647:5
   5: core::panicking::panic_fmt
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/panicking.rs:72:14
   6: core::result::unwrap_failed
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/result.rs:1649:5
   7: <core::result::Result<notify::inotify::INotifyWatcher, notify::error::Error>>::expect
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/result.rs:1030:23
   8: <fs::RealFs as fs::Fs>::watch::{closure#0}
             at crates/fs/src/fs.rs:431:34
   9: <core::pin::Pin<alloc::boxed::Box<dyn core::future::future::Future<Output = core::pin::Pin<alloc::boxed::Box<dyn futures_core::stream::Stream<Item = alloc::vec::Vec<std::path::PathBuf>> + core::marker::Send>>> + core::marker::Send>> as core::future::future::Future>::poll
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/future/future.rs:124:9
  10: <assistant::assistant_panel::AssistantPanel>::load::{closure#0}::{closure#0}::{closure#1}::{closure#0}::{closure#0}::{closure#0}
             at crates/assistant/src/assistant_panel.rs:127:30
  11: <core::pin::Pin<alloc::boxed::Box<dyn core::future::future::Future<Output = core::result::Result<(), anyhow::Error>>>> as core::future::future::Future>::poll
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/future/future.rs:124:9
  12: <<async_task::runnable::Builder<_>>::spawn_local::Checked<core::pin::Pin<alloc::boxed::Box<dyn core::future::future::Future<Output = core::result::Result<(), anyhow::Error>>>>> as core::future::future::Future>::poll
             at /home/kdwk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-task-4.7.0/src/runnable.rs:455:26
  13: <async_task::raw::RawTask<<async_task::runnable::Builder<_>>::spawn_local::Checked<core::pin::Pin<alloc::boxed::Box<dyn core::future::future::Future<Output = core::result::Result<(), anyhow::Error>>>>>, core::result::Result<(), anyhow::Error>, <gpui::executor::ForegroundExecutor>::spawn::inner<core::result::Result<(), anyhow::Error>>::{closure#0}, ()>>::run
             at /home/kdwk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-task-4.7.0/src/raw.rs:557:17
  14: <async_task::runnable::Runnable>::run
             at /home/kdwk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-task-4.7.0/src/runnable.rs:781:18
  15: <gpui::platform::linux::wayland::client::WaylandClient>::new::{closure#1}
             at crates/gpui/src/platform/linux/wayland/client.rs:285:17
  16: <core::cell::RefCell<calloop::sources::DispatcherInner<calloop::sources::channel::Channel<async_task::runnable::Runnable>, <gpui::platform::linux::wayland::client::WaylandClient>::new::{closure#1}>> as calloop::sources::EventDispatcher<gpui::platform::linux::wayland::client::WaylandClientStatePtr>>::process_events::{closure#0}
             at /home/kdwk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/calloop-0.12.4/src/sources/mod.rs:327:61
  17: <calloop::sources::channel::Channel<async_task::runnable::Runnable> as calloop::sources::EventSource>::process_events::<<core::cell::RefCell<calloop::sources::DispatcherInner<calloop::sources::channel::Channel<async_task::runnable::Runnable>, <gpui::platform::linux::wayland::client::WaylandClient>::new::{closure#1}>> as calloop::sources::EventDispatcher<gpui::platform::linux::wayland::client::WaylandClientStatePtr>>::process_events::{closure#0}>::{closure#0}
             at /home/kdwk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/calloop-0.12.4/src/sources/channel.rs:187:32
  18: <calloop::sources::ping::eventfd::PingSource as calloop::sources::EventSource>::process_events::<<calloop::sources::channel::Channel<async_task::runnable::Runnable> as calloop::sources::EventSource>::process_events<<core::cell::RefCell<calloop::sources::DispatcherInner<calloop::sources::channel::Channel<async_task::runnable::Runnable>, <gpui::platform::linux::wayland::client::WaylandClient>::new::{closure#1}>> as calloop::sources::EventDispatcher<gpui::platform::linux::wayland::client::WaylandClientStatePtr>>::process_events::{closure#0}>::{closure#0}>::{closure#0}
             at /home/kdwk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/calloop-0.12.4/src/sources/ping/eventfd.rs:138:21
  19: <calloop::sources::generic::Generic<calloop::sources::ping::eventfd::ArcAsFd> as calloop::sources::EventSource>::process_events::<<calloop::sources::ping::eventfd::PingSource as calloop::sources::EventSource>::process_events<<calloop::sources::channel::Channel<async_task::runnable::Runnable> as calloop::sources::EventSource>::process_events<<core::cell::RefCell<calloop::sources::DispatcherInner<calloop::sources::channel::Channel<async_task::runnable::Runnable>, <gpui::platform::linux::wayland::client::WaylandClient>::new::{closure#1}>> as calloop::sources::EventDispatcher<gpui::platform::linux::wayland::client::WaylandClientStatePtr>>::process_events::{closure#0}>::{closure#0}>::{closure#0}>
             at /home/kdwk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/calloop-0.12.4/src/sources/generic.rs:290:9
  20: <calloop::sources::ping::eventfd::PingSource as calloop::sources::EventSource>::process_events::<<calloop::sources::channel::Channel<async_task::runnable::Runnable> as calloop::sources::EventSource>::process_events<<core::cell::RefCell<calloop::sources::DispatcherInner<calloop::sources::channel::Channel<async_task::runnable::Runnable>, <gpui::platform::linux::wayland::client::WaylandClient>::new::{closure#1}>> as calloop::sources::EventDispatcher<gpui::platform::linux::wayland::client::WaylandClientStatePtr>>::process_events::{closure#0}>::{closure#0}>
             at /home/kdwk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/calloop-0.12.4/src/sources/ping/eventfd.rs:127:9
  21: <calloop::sources::channel::Channel<async_task::runnable::Runnable> as calloop::sources::EventSource>::process_events::<<core::cell::RefCell<calloop::sources::DispatcherInner<calloop::sources::channel::Channel<async_task::runnable::Runnable>, <gpui::platform::linux::wayland::client::WaylandClient>::new::{closure#1}>> as calloop::sources::EventDispatcher<gpui::platform::linux::wayland::client::WaylandClientStatePtr>>::process_events::{closure#0}>
             at /home/kdwk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/calloop-0.12.4/src/sources/channel.rs:184:9
  22: <core::cell::RefCell<calloop::sources::DispatcherInner<calloop::sources::channel::Channel<async_task::runnable::Runnable>, <gpui::platform::linux::wayland::client::WaylandClient>::new::{closure#1}>> as calloop::sources::EventDispatcher<gpui::platform::linux::wayland::client::WaylandClientStatePtr>>::process_events
             at /home/kdwk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/calloop-0.12.4/src/sources/mod.rs:326:9
  23: <calloop::loop_logic::EventLoop<gpui::platform::linux::wayland::client::WaylandClientStatePtr>>::dispatch_events
             at /home/kdwk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/calloop-0.12.4/src/loop_logic.rs:445:31
  24: <calloop::loop_logic::EventLoop<gpui::platform::linux::wayland::client::WaylandClientStatePtr>>::dispatch::<core::option::Option<core::time::Duration>>
             at /home/kdwk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/calloop-0.12.4/src/loop_logic.rs:559:9
  25: <calloop::loop_logic::EventLoop<gpui::platform::linux::wayland::client::WaylandClientStatePtr>>::run::<<gpui::platform::linux::wayland::client::WaylandClient as gpui::platform::linux::platform::LinuxClient>::run::{closure#0}, core::option::Option<core::time::Duration>>
             at /home/kdwk/.cargo/registry/src/index.crates.io-6f17d22bba15001f/calloop-0.12.4/src/loop_logic.rs:596:13
  26: <gpui::platform::linux::wayland::client::WaylandClient as gpui::platform::linux::platform::LinuxClient>::run
             at crates/gpui/src/platform/linux/wayland/client.rs:428:9
  27: <gpui::platform::linux::wayland::client::WaylandClient as gpui::platform::Platform>::run
             at crates/gpui/src/platform/linux/platform.rs:128:9
  28: <gpui::app::App>::run::<Zed::init_ui::{closure#3}>
             at crates/gpui/src/app.rs:142:9
  29: Zed::init_ui
             at crates/zed/src/main.rs:233:5
  30: Zed::main
             at crates/zed/src/main.rs:442:9
  31: <fn() as core::ops::function::FnOnce<()>>::call_once
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/ops/function.rs:250:5
  32: std::sys_common::backtrace::__rust_begin_short_backtrace::<fn(), ()>
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/sys_common/backtrace.rs:155:18
  33: std::rt::lang_start::<()>::{closure#0}
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/rt.rs:166:18
  34: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/core/src/ops/function.rs:284:13
      std::panicking::try::do_call
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:554:40
      std::panicking::try
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:518:19
      std::panic::catch_unwind
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panic.rs:142:14
      std::rt::lang_start_internal::{{closure}}
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/rt.rs:148:48
      std::panicking::try::do_call
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:554:40
      std::panicking::try
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panicking.rs:518:19
      std::panic::catch_unwind
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/panic.rs:142:14
      std::rt::lang_start_internal
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/rt.rs:148:20
  35: std::rt::lang_start::<()>
             at /rustc/25ef9e3d85d934b27d9dada2f9dd52b1dc63bb04/library/std/src/rt.rs:165:17
  36: main
  37: __libc_start_call_main
  38: __libc_start_main_impl
  39: _start

kdwk avatar May 01 '24 02:05 kdwk

I built Zed in a Debian 12 VM following the directions in the docs/wiki and in my case, it crashes on launch:

Thread "<unnamed>" panicked with "Could not start file watcher: Error { kind: Io(Os { code: 24, kind: Uncategorized, message: \"Too many open files\" }), paths: [] }" at crates/fs/src/fs.rs:433:10
   0: Zed::reliability::init_panic_hook::{closure#0}
             at /home/eil/zed/crates/zed/src/reliability.rs:83:29
   1: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2034:9
      std::panicking::rust_panic_with_hook
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:783:13
   2: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:657:13
   3: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:171:18
   4: rust_begin_unwind
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:645:5
   5: core::panicking::panic_fmt
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panicking.rs:72:14
   6: core::result::unwrap_failed
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/result.rs:1654:5
   7: <core::result::Result<notify::inotify::INotifyWatcher, notify::error::Error>>::expect
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/result.rs:1034:23
      <fs::RealFs as fs::Fs>::watch::{closure#0}
             at /home/eil/zed/crates/fs/src/fs.rs:425:32
   8: <core::pin::Pin<alloc::boxed::Box<dyn core::future::future::Future<Output = core::pin::Pin<alloc::boxed::Box<dyn futures_core::stream::Stream<Item = alloc::vec::Vec<std::path::PathBuf>> + core::marker::Send>>> + core::marker::Send>> as core::future::future::Future>::poll
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/future/future.rs:123:9
      settings::settings_file::watch_config_file::{closure#0}
             at /home/eil/zed/crates/settings/src/settings_file.rs:41:70
   9: <core::pin::Pin<alloc::boxed::Box<dyn core::future::future::Future<Output = ()> + core::marker::Send>> as core::future::future::Future>::poll
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/future/future.rs:123:9
      <async_task::raw::RawTask<core::pin::Pin<alloc::boxed::Box<dyn core::future::future::Future<Output = ()> + core::marker::Send>>, (), <gpui::executor::BackgroundExecutor>::spawn_internal<()>::{closure#0}, ()>>::run
             at /home/eil/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-task-4.7.0/src/raw.rs:557:17
  10: <async_task::runnable::Runnable>::run
             at /home/eil/.cargo/registry/src/index.crates.io-6f17d22bba15001f/async-task-4.7.0/src/runnable.rs:781:18
      <gpui::platform::linux::dispatcher::LinuxDispatcher>::new::{closure#1}::{closure#0}
             at /home/eil/zed/crates/gpui/src/platform/linux/dispatcher.rs:45:34
      std::sys_common::backtrace::__rust_begin_short_backtrace::<<gpui::platform::linux::dispatcher::LinuxDispatcher>::new::{closure#1}::{closure#0}, ()>
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys_common/backtrace.rs:155:18
  11: <std::thread::Builder>::spawn_unchecked_::<<gpui::platform::linux::dispatcher::LinuxDispatcher>::new::{closure#1}::{closure#0}, ()>::{closure#1}::{closure#0}
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/thread/mod.rs:528:17
      <core::panic::unwind_safe::AssertUnwindSafe<<std::thread::Builder>::spawn_unchecked_<<gpui::platform::linux::dispatcher::LinuxDispatcher>::new::{closure#1}::{closure#0}, ()>::{closure#1}::{closure#0}> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/panic/unwind_safe.rs:272:9
      std::panicking::try::do_call::<core::panic::unwind_safe::AssertUnwindSafe<<std::thread::Builder>::spawn_unchecked_<<gpui::platform::linux::dispatcher::LinuxDispatcher>::new::{closure#1}::{closure#0}, ()>::{closure#1}::{closure#0}>, ()>
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:552:40
      std::panicking::try::<(), core::panic::unwind_safe::AssertUnwindSafe<<std::thread::Builder>::spawn_unchecked_<<gpui::platform::linux::dispatcher::LinuxDispatcher>::new::{closure#1}::{closure#0}, ()>::{closure#1}::{closure#0}>>
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panicking.rs:516:19
      std::panic::catch_unwind::<core::panic::unwind_safe::AssertUnwindSafe<<std::thread::Builder>::spawn_unchecked_<<gpui::platform::linux::dispatcher::LinuxDispatcher>::new::{closure#1}::{closure#0}, ()>::{closure#1}::{closure#0}>, ()>
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/panic.rs:146:14
      <std::thread::Builder>::spawn_unchecked_::<<gpui::platform::linux::dispatcher::LinuxDispatcher>::new::{closure#1}::{closure#0}, ()>::{closure#1}
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/thread/mod.rs:527:30
      <<std::thread::Builder>::spawn_unchecked_<<gpui::platform::linux::dispatcher::LinuxDispatcher>::new::{closure#1}::{closure#0}, ()>::{closure#1} as core::ops::function::FnOnce<()>>::call_once::{shim:vtable#0}
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/core/src/ops/function.rs:250:5
  12: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2020:9
      <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/alloc/src/boxed.rs:2020:9
      std::sys::pal::unix::thread::Thread::new::thread_start
             at /rustc/9b00956e56009bab2aa15d7bff10916599e3d6d6/library/std/src/sys/pal/unix/thread.rs:108:17
  13: start_thread
             at ./nptl/pthread_create.c:442:8
  14: __GI___clone3
             at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

cu avatar May 10 '24 12:05 cu

Are the file watchers properly closed when a setting is edited? To me this sounds like the another file watcher is opened when the setting is edited, but the old one isn’t closed so it eventually reaches the max number of watchers which can be open.

someone13574 avatar May 29 '24 13:05 someone13574

@williamdes (or anyone else) Are you still having this issue?

If so, can you confirm the current ulimit settings of a running Zed process?

cat /proc/$(pidof zed)/limits |grep 'open files'

For example on my stock Ubuntu22 system I get the following:

Max open files            1048576              1048576              files  

notpeter avatar Jul 09 '24 20:07 notpeter

@williamdes (or anyone else) Are you still having this issue?

Yes, it will never go away as I have a lot of projects in my workspace. For now I did split into smaller workspaces

cat /proc/$(pidof zed-editor)/limits |grep 'open files'
# Max open files            1048576              1048576              files 

williamdes avatar Jul 10 '24 08:07 williamdes

I also get Too many open files whenever trying to open any folder, no matter how few files it contains. Debian 12, Zed 0.144.3.

On the first run of Zed, it displays the empty editor. I created a folder called $HOME/testfolder and put a single text file in it. When I try to open this folder as a project in Zed, it crashes.

2024-07-19T10:33:51-07:00 ERROR zed::reliability] {
  "thread": "main",
  "payload": "Could not start file watcher: Error { kind: Io(Os { code: 24, kind: Uncategorized, message: \"Too many open files\" }), paths: [] }",
  "location_data": {
    "file": "crates/fs/src/fs.rs",
    "line": 482
  },
  "backtrace": [
    "core::panicking::panic_fmt",
    "core::result::unwrap_failed",
    "<fs::RealFs as fs::Fs>::watch::{{closure}}",
    "assistant::context_store::ContextStore::new::{{closure}}::{{closure}}",
    "async_task::raw::RawTask<F,T,S,M>::run",
    "<gpui::platform::linux::x11::client::X11Client as gpui::platform::linux::platform::LinuxClient>::run",
    "gpui::platform::linux::platform::<impl gpui::platform::Platform for P>::run",
    "gpui::app::App::run",
    "zed::main",
    "std::sys_common::backtrace::__rust_begin_short_backtrace",
    "std::rt::lang_start::{{closure}}",
    "std::rt::lang_start_internal",
    "main",
    "__libc_start_main",
    "_start"
  ],
  "app_version": "0.144.3",
  "release_channel": "Zed",
  "os_name": "Linux X11",
  "os_version": "debian 12",
  "architecture": "x86_64",
  "panicked_on": 1721410431197,
  "installation_id": "650ec6a7-2702-4762-9037-af7589ab8b84",
  "session_id": "9e5226c3-7a35-483d-b67a-bd7a47deb7d5"
}

cdbennett avatar Jul 19 '24 17:07 cdbennett

The error message we get in this case is a bit confusing.

"Could not start file watcher" is propagating the error from inotify_init. And inotify can return "too many open files" in three cases (from https://man7.org/linux/man-pages/man2/inotify_init.2.html).

  • You have run out of inotify instances (default 128) in /proc/sys/fs/inotify/max_user_instances
  • You have run out of file descriptors on the system
  • You have run out of per user file descriptors

Separately inotify_add_watch can fail because of exceeding max watches; but that doesn't seem to be the case if we're failing at this point.

I suspect that we're hitting the first limit. Can you confirm that you have a reasonable value in /proc/sys/fs/inotify/max_user_instances?

A change I intend to make is to make Zed use one global inotify instance (right now we create 1 per worktree + a few for settings/extensions/etc.) which should reduce the likelihood of the error if we're close to the limit

ConradIrwin avatar Jul 19 '24 18:07 ConradIrwin

The error message we get in this case is a bit confusing.

"Could not start file watcher" is propagating the error from inotify_init. And inotify can return "too many open files" in three cases (from https://man7.org/linux/man-pages/man2/inotify_init.2.html).

* You have run out of inotify instances  (default 128) in `/proc/sys/fs/inotify/max_user_instances`

...

I suspect that we're hitting the first limit. Can you confirm that you have a reasonable value in /proc/sys/fs/inotify/max_user_instances?

You are correct, increasing the inotify max user instances limit solved the problem. Thanks!

For reference, I added this setting to my /etc/sysctl.conf to increase it from the default of 128:

fs.inotify.max_user_instances = 524288

Now Zed is working.

cdbennett avatar Jul 23 '24 19:07 cdbennett

Also, if anyone else is having any inotify problems, try using this little tool. Very helpful:

https://github.com/mikesart/inotify-info/

cdbennett avatar Jul 23 '24 19:07 cdbennett

@williamdes Can you try this with the newest Zed Preview release (0.147.x) and see if you're still having the issue?

notpeter avatar Aug 02 '24 15:08 notpeter

@williamdes Can you try this with the newest Zed Preview release (0.147.x) and see if you're still having the issue?

Seems to not crash anymore, I added my /mnt folder and it did not crash

williamdes avatar Aug 07 '24 08:08 williamdes