astral-sh/ruff · error · std::io::Error

NotFound

NotFound

Error message

No such file or directory

What it means

The WASM build replaces the OS with an in-memory system (WasmSystem). Reads of system paths that were never written through openFile/write_file return ErrorKind::NotFound with the conventional ENOENT message produced by the not_found() helper.

Source

Thrown at crates/ty_wasm/src/lib.rs:1717

    fn as_writable(&self) -> Option<&dyn WritableSystem> {
        None
    }

    fn as_any(&self) -> &dyn Any {
        self
    }

    fn as_any_mut(&mut self) -> &mut dyn Any {
        self
    }

    fn dyn_clone(&self) -> Box<dyn System> {
        Box::new(self.clone())
    }
}

fn not_found() -> std::io::Error {
    std::io::Error::new(std::io::ErrorKind::NotFound, "No such file or directory")
}

View on GitHub (pinned to d1087a4b9e)

Solutions

  1. Open every file ty needs (openFile) or fix search paths before running checks
  2. Pre-validate that required paths exist in the virtual FS before analysis
  3. Treat NotFound during optional-file resolution as skippable instead of letting it abort the run

Example fix

// before
db.check('/project/main.py'); // imports numpy, never provided -> NotFound

// after
db.openFile('/site-packages/numpy/__init__.py', numpySource);
db.check('/project/main.py');
Defensive patterns

Strategy: validation

Validate before calling

// Provide required files before analysis
const required = ['/project/main.py', '/site-packages/dep/__init__.py'];
for (const [p, src] of requiredFiles) { if (!opened.has(p)) db.openFile(p, src); }

Try / catch

try { analyze(); } catch (e) { if (String(e).includes('No such file or directory')) { /* open missing file, retry once */ } else throw e; }

Prevention

When it happens

Trigger: Analysis or an explicit read touches a system path whose contents were never provided from JS: an import target that was never opened, a search-path entry with no backing files, or a stale path after reconfiguration.

Common situations: Forgetting to openFile a dependency before check; misconfigured searchPaths pointing at files not uploaded into the WASM instance; project settings switched to reference unavailable files.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of astral-sh/ruff@d1087a4b9e (2026-08-20). Data as JSON: /api/errors/70c9376b9fb92f42. Report an issue: GitHub.