vercel/next.js · error

reading file {}

Error message

reading file {}

What it means

An anyhow error-context wrapper produced by extract_disk_access() in turbo-tasks-fs: any std::io error that is NOT NotFound or InvalidFilename (e.g. PermissionDenied, a disk I/O failure) is wrapped with the context 'reading file <path>'. This is a generic filesystem-read failure surfaced by Turbopack's virtual filesystem layer.

Source

Thrown at turbopack/crates/turbo-tasks-fs/src/util.rs:20

    io::{self, ErrorKind},
    path::Path,
};

use anyhow::{Context, Result, anyhow};
use turbo_tasks::ResolvedVc;
use url::Url;

use crate::{DiskFileSystem, FileSystemPath};

/// Converts a disk access `Result<T>` into a `Result<Some<T>>`, where a [`ErrorKind::NotFound`] (or
/// [`ErrorKind::InvalidFilename`]) error results in a [`None`] value. This is purely to reduce
/// boilerplate code comparing [`ErrorKind::NotFound`] errors against all other errors.
pub fn extract_disk_access<T>(value: io::Result<T>, path: &Path) -> Result<Option<T>> {
    match value {
        Ok(v) => Ok(Some(v)),
        Err(e) if matches!(e.kind(), ErrorKind::NotFound | ErrorKind::InvalidFilename) => Ok(None),
        // ast-grep-ignore: no-context-format
        Err(e) => Err(anyhow!(e).context(format!("reading file {}", path.display()))),
    }
}

pub async fn uri_from_file(root: FileSystemPath, path: Option<&str>) -> Result<String> {
    let root_fs = root.fs;
    let root_fs = &*ResolvedVc::try_downcast_type::<DiskFileSystem>(root_fs)
        .context("Expected root to have a DiskFileSystem")?
        .await?;

    let path = match path {
        Some(path) => root.join(path)?,
        None => root,
    };

    // `to_sys_path` returns a win32 path on Windows. `Url::from_file_path` can also handle
    // verbatim (`\\?\`-prefixed) disk and UNC paths, in case that conversion failed.
    let sys_path = root_fs.to_sys_path(&path);
    Ok(String::from(Url::from_file_path(&sys_path).map_err(

View on GitHub (pinned to 0ae8c72462)

Solutions

  1. Check the underlying io::Error kind in the cause chain (permission denied, etc.) and fix that specific OS-level issue.
  2. Verify the Next.js process has read permissions on the path shown in the message.
  3. Ensure the file/path still exists and isn't a broken symlink during the build.
  4. Re-run the build after resolving the filesystem issue; transient NFS/network FS errors often clear.
Defensive patterns

Strategy: try-catch

Prevention

When it happens

Trigger: Turbopack attempts to read a file that exists but the OS denies access or the read fails — permission denied, file locked, disk error, symlink loop, or path-too-long — during a build/dev compilation.

Common situations: File permissions too restrictive for the Next.js process; a file deleted/moved mid-build causing a transient read error; network-mounted filesystem hiccup; running the dev server as a different user than owns the files.

Related errors


AI-assisted analysis of vercel/next.js@0ae8c72462 (2026-08-06). Data as JSON: /api/errors/885a334ce450d1cd. Report an issue: GitHub.