biomejs/biome · error

To be a UTF-8 path

Error message

To be a UTF-8 path

What it means

Error "To be a UTF-8 path" thrown in biomejs/biome.

Source

Thrown at crates/biome_fs/src/fs/os.rs:43

use super::{BoxedTraversal, File, FileSystemDiagnostic, FsErrorKind, PathKind};

/// Implementation of [FileSystem] that directly calls through to the underlying OS
pub struct OsFileSystem {
    pub working_directory: Option<Utf8PathBuf>,
}

impl OsFileSystem {
    pub fn new(working_directory: Utf8PathBuf) -> Self {
        Self {
            working_directory: Some(working_directory),
        }
    }
}

impl Default for OsFileSystem {
    fn default() -> Self {
        let working_directory = env::current_dir()
            .map(|p| Utf8PathBuf::from_path_buf(p).expect("To be a UTF-8 path"))
            .ok();
        Self { working_directory }
    }
}

impl FileSystem for OsFileSystem {
    fn open_with_options(
        &self,
        path: &Utf8Path,
        options: OpenOptions,
    ) -> io::Result<Box<dyn File>> {
        let mut fs_options = fs::File::options();
        Ok(Box::new(OsFile {
            inner: options.into_fs_options(&mut fs_options).open(path)?,
            version: 0,
        }))
    }

View on GitHub (pinned to 405dedb0ff)

Solutions

  1. Use paths that are valid UTF-8; on Unix, avoid non-UTF-8 byte sequences in file names.
  2. Convert the path to a UTF-8 representation before passing it to Biome.

Example fix

let utf8 = path.to_str().ok_or_else(|| /* non-UTF-8 path error */)?;

When it happens

Trigger: Thrown at crates/biome_fs/src/fs/os.rs:43 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of biomejs/biome@405dedb0ff (2026-08-20). Data as JSON: /api/errors/47a5f5c76db8019e. Report an issue: GitHub.