{"record":{"id":"6f8b213f00793898","repo":"sxyazi/yazi","slug":"unsupported-os-for-trash-operation","errorCode":null,"errorMessage":"Unsupported OS for trash operation","messagePattern":"Unsupported OS for trash operation","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-fs/src/engine/local/local.rs","lineNumber":197,"sourceCode":"\t\t{\n\t\t\ttokio::fs::symlink_file(original, self.path).await\n\t\t}\n\t}\n\n\t#[inline]\n\tasync fn symlink_metadata(&self) -> io::Result<Cha> {\n\t\tOk(Cha::new(\n\t\t\tself.path.file_name().unwrap_or_default(),\n\t\t\ttokio::fs::symlink_metadata(self.path).await?,\n\t\t))\n\t}\n\n\tasync fn trash(&self) -> io::Result<()> {\n\t\tlet path = self.path.to_owned();\n\t\ttokio::task::spawn_blocking(move || {\n\t\t\t#[cfg(target_os = \"android\")]\n\t\t\t{\n\t\t\t\tErr(io::Error::new(io::ErrorKind::Unsupported, \"Unsupported OS for trash operation\"))\n\t\t\t}\n\t\t\t#[cfg(target_os = \"macos\")]\n\t\t\t{\n\t\t\t\tuse trash::{TrashContext, macos::{DeleteMethod, TrashContextExtMacos}};\n\t\t\t\tlet mut ctx = TrashContext::default();\n\t\t\t\tctx.set_delete_method(DeleteMethod::NsFileManager);\n\t\t\t\tctx.delete(path).map_err(io::Error::other)\n\t\t\t}\n\t\t\t#[cfg(all(not(target_os = \"macos\"), not(target_os = \"android\")))]\n\t\t\t{\n\t\t\t\ttrash::delete(path).map_err(io::Error::other)\n\t\t\t}\n\t\t})\n\t\t.await?\n\t}\n\n\t#[inline]\n\tfn url(&self) -> Url<'_> { self.url }","sourceCodeStart":179,"sourceCodeEnd":215,"githubUrl":"https://github.com/sxyazi/yazi/blob/a541adde4e5b082719a0f21a87eb3eab071ece58/yazi-fs/src/engine/local/local.rs#L179-L215","documentation":"Local::trash moves a file to the OS trash via the `trash` crate. On Android (target_os = \"android\") there is no supported trash backend, so the implementation deliberately returns io::ErrorKind::Unsupported with \"Unsupported OS for trash operation\". This is a compile-time platform limitation, not a runtime misconfiguration.","triggerScenarios":"Calling trash() on a file handle while the code is compiled for Android (target_os = \"android\"), e.g. via a delete-to-trash operation from the file manager or a `delete --permanent=false` style flow.","commonSituations":"Running yazi on Android (e.g. via Termux) and issuing a trash/delete operation; CI or cross-compilation targeting android and exercising the trash code path in tests.","solutions":["Use permanent deletion instead of trash on Android, or skip the trash option in the UI on this platform (cfg-gate the feature).","Implement a userspace trash (move files to an app-private .Trash directory) as a fallback on Android.","Catch io::ErrorKind::Unsupported from the trash call and surface a clear 'not supported on this OS' message to the user."],"exampleFix":"// before\nfile.trash().await?;\n// after\nif cfg!(target_os = \"android\") {\n    return Err(anyhow!(\"moving to trash is not supported on Android; delete permanently instead\"));\n}\nfile.trash().await?;","handlingStrategy":"try-catch","validationCode":"// Rust\nlet trash_supported = !cfg!(target_os = \"android\");","typeGuard":null,"tryCatchPattern":"match file.trash().await {\n    Err(e) if e.kind() == std::io::ErrorKind::Unsupported => ui.notify(\"Trash is not supported on this OS\"),\n    other => other?,\n}","preventionTips":["Gate trash-dependent UI behind target_os checks at startup.","Offer permanent deletion as an alternative on unsupported platforms.","Test platform-specific code paths in CI for android targets."],"tags":["trash","android","platform-unsupported","io"],"backgroundTag":"os-not-supported","analyzedSha":"a541adde4e5b082719a0f21a87eb3eab071ece58","analyzedAt":"2026-09-02T18:38:25.566Z","contentChangedAt":"2026-09-02T18:38:25.566Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}