− let msg = format!(
− "Error setting up file watch for path {}: {err:?}",
− entry.path().to_string_lossy()
− );
+ let msg = if let notify::ErrorKind::MaxFilesWatch = &err.kind {
+ {
+ if already_got_max_files_err {
+ continue;
+ } else {
+ already_got_max_files_err = true;
+ }
+ }
+ #[cfg(target_os = "linux")]
+ const HELP: &str = " Consider increasing the limits (`fs.inotify.max_user_instances` and/or `fs.inotify.max_user_watches`)";
+ #[cfg(not(target_os = "linux"))]
+ const MORE: &str = "";
+ format!("Error setting up file watch. Reached a maximum.{HELP}")
+ } else {
+ format!(
+ "Error setting up file watch for path {}: {err:?}",
+ entry.path().to_string_lossy()
+ )
+ };