sxyazi/yazi · error · io::Error

Url has no parent

Error message

Url has no parent

What it means

Error "Url has no parent" thrown in sxyazi/yazi.

Source

Thrown at yazi-scheduler/src/file/transaction.rs:20

use yazi_fs::{cha::ChaMode, engine::Attrs};
use yazi_macro::ok_or_not_found;
use yazi_shared::{timestamp_us, url::{AsUrl, Url, UrlBuf}};
use yazi_vfs::{engine, unique_file};

pub(super) struct Transaction;

impl Transaction {
	pub(super) async fn tmp<U>(url: U) -> io::Result<UrlBuf>
	where
		U: AsUrl,
	{
		Self::tmp_impl(url.as_url()).await
	}

	async fn tmp_impl(url: Url<'_>) -> io::Result<UrlBuf> {
		let Some(parent) = url.parent() else {
			Err(io::Error::new(io::ErrorKind::InvalidInput, "Url has no parent"))?
		};

		let mut h = foldhash::fast::FixedState::default().build_hasher();
		url.hash(&mut h);
		timestamp_us().hash(&mut h);

		unique_file(parent.try_join(format!(".{:x}.%tmp", h.finish()))?, false).await
	}

	pub(super) async fn unlink<U>(url: U) -> io::Result<()>
	where
		U: AsUrl,
	{
		let url = url.as_url();

		let cha = ok_or_not_found!(engine::symlink_metadata(url).await, return Ok(()));
		if cha.is_indirect() {
			engine::rename(Self::tmp(url).await?, url).await?;

View on GitHub (pinned to 441b332de8)

Solutions

  1. The URL has no parent (it is a root); ensure the file operation is not attempted on a root URL.

When it happens

Trigger: Thrown at yazi-scheduler/src/file/transaction.rs:20 when the library encounters an invalid state.

Common situations: Computing the parent of a root-level URL during a file transaction, e.g. moving a filesystem root.


AI-assisted analysis of sxyazi/yazi@441b332de8 (2026-08-19). Data as JSON: /api/errors/5a1c9ac4889ce8f5. Report an issue: GitHub.