astral-sh/ruff · error · Error

File does not exist

Error message

File does not exist

What it means

A wasm-bindgen Error from ty's updateFile binding: the target file does not exist on the wasm system's filesystem, so there is nothing to update. The existence check runs before any write is attempted.

Solutions

  1. Create the file first with the create/open API before updating
  2. Check the file handle is still valid before calling updateFile
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/ty_wasm/src/lib.rs:221 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of astral-sh/ruff@5bb508f594 (2026-09-05). Data as JSON: /api/errors/3ca781b42f04170e. Report an issue: GitHub.

Appendix: source

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

        let file = system_path_to_file(&self.db, &path).expect("File to exist");

        self.db.project().open_file(&mut self.db, file);

        Ok(FileHandle {
            path: path.into(),
            file,
        })
    }

    #[wasm_bindgen(js_name = "updateFile")]
    pub fn update_file(&mut self, file_id: &FileHandle, contents: &str) -> Result<(), Error> {
        let system_path = file_id.path.as_system_path().ok_or_else(|| {
            Error::new("Cannot update non-system files (vendored files are read-only)")
        })?;

        if !self.system.fs.exists(system_path) {
            return Err(Error::new("File does not exist"));
        }

        self.system
            .fs
            .write_file(system_path, contents)
            .map_err(into_error)?;

        self.db.apply_changes(&[
            ChangeEvent::Changed {
                path: system_path.to_path_buf(),
                kind: ChangedKind::FileContent,
            },
            ChangeEvent::Changed {
                path: system_path.to_path_buf(),
                kind: ChangedKind::FileMetadata,
            },
        ]);

View on GitHub (pinned to 5bb508f594)