sxyazi/yazi · error · io::Error

invalid trash mount point

Error message

invalid trash mount point

What it means

`TrashInfo::mount_point` (trash_info.rs:88) computes the mount point that relative `Path=` values resolve against: for a top-level trash `<mp>/.Trash/<uid>` it strips both segments, otherwise it takes the parent of `<mp>/Trash`. If the computed ancestor does not exist (e.g. the trash root is `/` so it has no parent), it returns `ErrorKind::InvalidData`, `invalid trash mount point`.

Source

Thrown at yazi-fs/src/trash/freedesktop/trash_info.rs:88

				Self::mount_point(root)?.join(path)
			});
		}
	}

	// /mnt/disk/.Trash/1000           =>  /mnt/disk
	// /home/alice/.local/share/Trash  =>  /home/alice/.local/share
	fn mount_point(root: &Path) -> io::Result<&Path> {
		let uid = USERS_CACHE.get_current_uid().to_string();

		if root.file_name() == Some(OsStr::new(&uid))
			&& let Some(parent) = root.parent()
			&& parent.file_name() == Some(OsStr::new(".Trash"))
		{
			parent.parent()
		} else {
			root.parent()
		}
		.ok_or_else(|| io::Error::new(io::ErrorKind::InvalidData, "invalid trash mount point"))
	}

	fn trim_line(line: &mut Vec<u8>) {
		while matches!(line.last(), Some(b'\n' | b'\r')) {
			line.pop();
		}
	}
}

View on GitHub (pinned to 94abcfa92f)

Solutions

  1. Fix the `Path=` in the `.trashinfo` to an absolute path so mount-point resolution is skipped entirely.
  2. Relocate the trash to a standard location (`$XDG_DATA_HOME/Trash` or `<mount>/.Trash/$uid`) so a parent exists.
  3. Delete the degenerate trash metadata if the item is not worth salvaging.

Example fix

# before: relative Path forces mount_point() on a root-level trash
[Trash Info]
Path=report.pdf

# after
[Trash Info]
Path=/home/alice/report.pdf
Defensive patterns

Strategy: try-catch

Validate before calling

// only relevant when Path= is relative: ensure the trash root has a parent
if !path.is_absolute() && root.parent().is_none() {
    // mount point cannot be derived; rewrite Path= as absolute instead
}

Try / catch

match trash.entry(&id) {
    Ok(e) => { /* ... */ }
    Err(e) if e.kind() == io::ErrorKind::InvalidData => {
        // undecodable mount point: make Path= absolute so mount_point() is never called
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: A `.trashinfo` whose `Path=` is relative (forcing mount-point resolution) while its trash root is at or effectively at the filesystem root, leaving no parent to return.

Common situations: Trash directories created at `/` or under paths with deleted/moved parents; exotic layouts where `root.parent()` is None; essentially only reachable with malformed on-disk state.

Related errors


AI-assisted analysis of sxyazi/yazi@94abcfa92f (2026-08-16). Data as JSON: /api/errors/09d90e186f239ee5. Report an issue: GitHub.