biomejs/biome · error · io::Error

this file wasn't open with write access

Error message

this file wasn't open with write access

What it means

Error "this file wasn't open with write access" thrown in biomejs/biome.

Source

Thrown at crates/biome_fs/src/fs/memory.rs:282

    fn read_to_string(&mut self, buffer: &mut String) -> io::Result<()> {
        if !self.can_read {
            return Err(io::Error::new(
                io::ErrorKind::PermissionDenied,
                "this file wasn't open with read access",
            ));
        }

        // Verify the stored byte content is valid UTF-8
        let content = str::from_utf8(&self.inner)
            .map_err(|err| io::Error::new(io::ErrorKind::InvalidData, err))?;
        // Append the content of the file to the buffer
        buffer.push_str(content);
        Ok(())
    }

    fn set_content(&mut self, content: &[u8]) -> io::Result<()> {
        if !self.can_write {
            return Err(io::Error::new(
                io::ErrorKind::PermissionDenied,
                "this file wasn't open with write access",
            ));
        }

        // Resize the memory buffer to fit the new content
        self.inner.resize(content.len(), 0);
        // Copy the new content into the memory buffer
        self.inner.copy_from_slice(content);
        // we increase its version
        self.version += 1;
        Ok(())
    }

    fn file_version(&self) -> i32 {
        self.version
    }
}

View on GitHub (pinned to 405dedb0ff)

Solutions

  1. Open the file with write access (`OpenOptions::write(true)`) before calling `set_content` or writing.

Example fix

let mut file = fs.open_with_options(path, OpenOptions::default().write(true))?; file.set_content(content)?;

When it happens

Trigger: Thrown at crates/biome_fs/src/fs/memory.rs:282 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/e91f8fea70efe355. Report an issue: GitHub.