{"record":{"id":"fbd26480dd8576c2","repo":"libnyanpasu/clash-nyanpasu","slug":"couldn-t-get-file-name-of-curent-executable","errorCode":null,"errorMessage":"Couldn't get file name of curent executable.","messagePattern":"Couldn't get file name of curent executable\\.","errorType":"exception","errorClass":"std::io::Error (NotFound)","httpStatus":null,"severity":"error","filePath":"backend/tauri-plugin-deep-link/src/linux.rs","lineNumber":26,"sourceCode":"use dirs::data_dir;\n\nuse crate::ID;\n\npub fn register<F: FnMut(String) + Send + 'static>(schemes: &[&str], handler: F) -> Result<()> {\n    listen(handler)?;\n\n    let mut target = data_dir()\n        .ok_or_else(|| Error::new(ErrorKind::NotFound, \"data directory not found.\"))?\n        .join(\"applications\");\n\n    create_dir_all(&target)?;\n\n    let exe = tauri_utils::platform::current_exe()?;\n\n    let file_name = format!(\n        \"{}-handler.desktop\",\n        exe.file_name()\n            .ok_or_else(|| Error::new(\n                ErrorKind::NotFound,\n                \"Couldn't get file name of curent executable.\",\n            ))?\n            .to_string_lossy()\n    );\n\n    target.push(&file_name);\n\n    let mime_types = format!(\n        \"{};\",\n        schemes\n            .iter()\n            .map(|s| format!(\"x-scheme-handler/{}\", s))\n            .collect::<Vec<String>>()\n            .join(\";\")\n    );\n\n    let mut file = File::create(&target)?;","sourceCodeStart":8,"sourceCodeEnd":44,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/tauri-plugin-deep-link/src/linux.rs#L8-L44","documentation":"The Linux deep-link register() names the generated .desktop file after the current executable (`<name>-handler.desktop`). It calls current_exe().file_name(); when the executable path has no final component (root of a filesystem, deleted path, or exotic exec setup), it fails with this NotFound io::Error.","triggerScenarios":"register() invoked when std::env::current_exe() / tauri's current_exe returns a path whose file_name() is None — e.g. the binary path is \"/\", the path was unlinked after exec, or running via unusual mount setups.","commonSituations":"Container or chroot layouts where /proc/self/exe resolves oddly; app executed from a deleted temp directory; memory-fd execution; symlinks pointing to filesystem root after misconfiguration.","solutions":["Ensure the app is launched from a normal on-disk executable path with a file name","Check the inner path: log tauri_utils::platform::current_exe() to see what path was resolved","Avoid running the binary from paths like \"/\" or from unlinked temp files","If the exotic launch mode is intentional, generate a stable .desktop name from a constant (e.g. the app identifier) instead of exe.file_name()"],"exampleFix":"// before\nexe.file_name().ok_or_else(|| Error::new(ErrorKind::NotFound, \"Couldn't get file name of curent executable.\"))?\n// after\nlet name = exe.file_name().map(|n| n.to_string_lossy().into_owned())\n    .unwrap_or_else(|| \"nyanpasu\".to_string());\nlet file_name = format!(\"{name}-handler.desktop\");","handlingStrategy":"validation","validationCode":"// before register()\nlet exe = tauri_utils::platform::current_exe()?;\nif exe.file_name().is_none() {\n    anyhow::bail!(\"current exe path {:?} has no file name; cannot build .desktop name\", exe);\n}","typeGuard":"fn exe_has_file_name(path: &std::path::Path) -> bool {\n    path.file_name().is_some()\n}","tryCatchPattern":"match deep_link::register(&schemes, handler) {\n    Err(e) if e.to_string().contains(\"file name of curent executable\") => {\n    log::error!(\"exe path unusable for .desktop naming: {e}\");\n    }\n    Err(e) => return Err(e.into()),\n    Ok(()) => {}\n}","preventionTips":["Launch the app from a normal on-disk path, never \"/\" or unlinked temp files","Log current_exe() at startup to detect odd resolution environments early","Prefer a constant .desktop name derived from the app identifier over exe-derived names in exotic setups"],"tags":["linux","deep-link","filesystem"],"backgroundTag":"file-not-found","analyzedSha":"f7dbce2997c633e484f54788035e770b3ee99773","analyzedAt":"2026-09-08T01:24:59.197Z","contentChangedAt":"2026-09-08T01:24:59.197Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}