astral-sh/ruff · error

Virtual path does not exist: {path}

Error message

Virtual path does not exist: {path}

What it means

Sentinel io::Error (ErrorKind::NotFound) produced by the ty_server helper virtual_path_not_found when a file operation targets a path in ty's virtual (in-memory, LSP-managed) filesystem that has no corresponding entry. read_virtual_path_to_string and read_virtual_path_to_notebook call it instead of touching the OS filesystem so that requests for unsaved/virtual documents fail as a clean NotFound rather than an ENOENT from disk. Callers match on the kind to map it into an LSP 'file not found' response; callers should check virtual existence before invoking these readers.

Source

Thrown at crates/ty_server/src/system.rs:345

            std::io::ErrorKind::PermissionDenied,
            "external commands are disabled in an untrusted workspace",
        ))
    }

    fn dyn_clone(&self) -> Box<dyn CommandExecutor> {
        Box::new(Self)
    }
}

fn not_a_text_document(path: impl Display) -> std::io::Error {
    std::io::Error::new(
        std::io::ErrorKind::InvalidInput,
        format!("Input is not a text document: {path}"),
    )
}

fn virtual_path_not_found(path: impl Display) -> std::io::Error {
    std::io::Error::new(
        std::io::ErrorKind::NotFound,
        format!("Virtual path does not exist: {path}"),
    )
}

/// Helper function to get the [`FileRevision`] of the given document.
fn document_revision(document: &Document, index: &Index) -> FileRevision {
    // The file revision is just an opaque number which doesn't have any significant meaning other
    // than that the file has changed if the revisions are different.
    #[expect(clippy::cast_sign_loss)]
    match document {
        Document::Text(text) => FileRevision::new(text.version() as u128),
        Document::Notebook(notebook) => {
            // VS Code doesn't always bump the notebook version when the cell content changes.
            // Specifically, I noticed that VS Code re-uses the same version when:
            // 1. Adding a new cell
            // 2. Pasting some code that has an error
            //

View on GitHub (pinned to 26f38c119c)

Solutions

  1. Verify the virtual path exists before reading
  2. Handle NotFound at the call site and skip the missing virtual file
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at crates/ty_server/src/system.rs:345 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of astral-sh/ruff@26f38c119c (2026-09-05). Data as JSON: /api/errors/09d5f24049402e09. Report an issue: GitHub.