astral-sh/ruff · error · NotebookError
Reading a notebook from the vendored file system is not supp
Error message
Reading a notebook from the vendored file system is not supported.
What it means
This NotebookError wraps an io::Error (kind InvalidInput) thrown when `read_to_notebook` is called on a file whose path lives on the vendored file system. Notebooks can only be read from the real system file system; vendored (in-memory, bundled) paths do not support notebook deserialization, so the query deliberately returns this error.
Source
Thrown at crates/ruff_db/src/files.rs:439
}
}
}
/// Reads the content of the file into a [`Notebook`].
///
/// Reading the same file multiple times isn't guaranteed to return the same content. It's possible
/// that the file has been modified in between the reads.
pub(crate) fn read_to_notebook(&self, db: &dyn Db) -> Result<Notebook, NotebookError> {
let path = self.path(db);
match path {
FilePath::System(system) => {
// Add a dependency on the revision to ensure the operation gets re-executed when the file changes.
let _ = self.revision(db);
db.system().read_to_notebook(system)
}
FilePath::Vendored(_) => Err(NotebookError::Io(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"Reading a notebook from the vendored file system is not supported.",
))),
FilePath::SystemVirtual(system_virtual) => {
// Add a dependency on the revision to ensure the operation gets re-executed when the file changes.
let _ = self.revision(db);
db.system().read_virtual_path_to_notebook(system_virtual)
}
}
}
/// Refreshes the file metadata by querying the file system if needed.
///
/// Directory listings are invalidated if the path's file status changed, its prior status is
/// unknown, or if `path` is itself a directory.
pub fn sync_path(db: &mut dyn Db, path: &SystemPath) {
let absolute = SystemPath::absolute(path, db.system().current_directory());View on GitHub (pinned to 26f38c119c)
Solutions
- Check `file.path(db)` and skip vendored paths before requesting notebook contents
- Fall back to plain `read_text`/stub handling for vendored files instead of notebook parsing
- Fix path resolution so real notebooks map to `FilePath::System`
Example fix
// before
let notebook = file.read_to_notebook(db)?;
// after
if matches!(file.path(db), FilePath::Vendored(_)) {
return Ok(None); // vendored files are never notebooks
}
let notebook = file.read_to_notebook(db)?; Defensive patterns
Strategy: type-guard
Validate before calling
path_kind = type(file.path(db))
if path_kind is FilePath.Vendored:
skip_notebook_read(file) Type guard
fn is_system_file(file: &File<'_>, db: &dyn Files) -> bool {
matches!(file.path(db), FilePath::System(_))
} Try / catch
match file.read_to_notebook(db) {
Err(e) if matches!(e.io_error_kind(), Some(std::io::ErrorKind::InvalidInput)) => Ok(None),
Err(e) => Err(e),
Ok(nb) => Ok(Some(nb)),
} Prevention
- Check FilePath kind before any notebook-specific read
- Treat vendored paths as stub-only resources
- Fix path resolution so user notebooks always map to system paths
When it happens
Trigger: Calling `source_text`/`read_to_notebook` on a `File` whose `FilePath` is `FilePath::Vendored(_)` — e.g. ty resolving a notebook path that resolves to a vendored typeshed/bundled resource.
Common situations: Analysis code that assumes every file with a `.ipynb`-style path is on disk, tests or tools pointing at vendored stubs, path-resolution bugs mapping a user notebook to the vendored FS.
Related errors
- directory listings are only supported for system paths
- NotFound
- System should be writable
- File name should be non-null because path is guaranteed to b
- Working directory does not exist
AI-assisted analysis of astral-sh/ruff@26f38c119c (2026-09-05).
Data as JSON: /api/errors/9fddd8106b8abd61.
Report an issue: GitHub.