Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kqueue always returns an "No such file or directory" on Watcher::unwatch #665

Open
squidfunk opened this issue Jan 9, 2025 · 1 comment

Comments

@squidfunk
Copy link

System details

  • OS/Platform name and version: macOS 13.0 Ventura
  • Rust version (if building from source): rustc --version: rustc 1.81.0 (eeb90cda1 2024-09-04)
  • Notify version (or commit hash if building from git): 7.0.0 with macos_kqueue feature flag
  • If you're running as a privileged user (root, System): -
  • If you're running in a container, details on the runtime and overlay: -
  • If you're running in a VM, details on the hypervisor: -

What you did (as detailed as you can)

I'm trying to use kqueue on macOS, but Watcher::unwatch always returns an error. Here is a minimal reproduction:

mkdir kqueue_repro && cd kqueue_repro
cargo init .
cargo add notify --features macos_kqueue

Source of the program:

use std::error::Error;
use std::path::PathBuf;
use notify::{recommended_watcher, RecursiveMode, Watcher};

fn main() -> Result<(), Box<dyn Error>> {
    let path = PathBuf::from("src");

    let mut watcher = recommended_watcher(|event| println!("{:?}", event))?;
    watcher.watch(&path, RecursiveMode::Recursive)?;
    watcher.unwatch(&path)?; // <- This always returns "No such file or directory"

    Ok(())
}

Stepping through the source of kqueue.rs, and subsequently the kqueue crate, the error seems to be triggered in Watcher::remove_filename, specifically when calling Watcher::delete_kevents. What's also very weird is that when I try to set a break point in this function CodeLLDB goes absolutely nuts and allocates more than 40 GB before my computer goes poof.

What you expected

Watcher::unwatch does not throw.

What happened

Error: Error { kind: Generic("No such file or directory (os error 2) about [\".../src\"]"), paths: [] }
@alexvoss
Copy link

alexvoss commented Jan 9, 2025

Ran the reproduction and it shows the same error on my MacOS Sonoma 14.7 (23H124) machine.

rustc --version 
rustc 1.83.0 (90b35a623 2024-11-26) (Homebrew)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants