{"record":{"id":"f4a0a6c235e79a72","repo":"libnyanpasu/clash-nyanpasu","slug":"file-symlinks-are-unsupported-on-this-platform","errorCode":null,"errorMessage":"file symlinks are unsupported on this platform","messagePattern":"file symlinks are unsupported on this platform","errorType":"exception","errorClass":"std::io::Error (Unsupported)","httpStatus":null,"severity":"error","filePath":"backend/tauri/src/service/profile_file.rs","lineNumber":497,"sourceCode":"    #[cfg(not(windows))]\n    {\n        name == MATERIALIZATION_ROOT\n    }\n}\n\nfn create_file_symlink(target: &Path, link: &Path) -> std::io::Result<()> {\n    #[cfg(windows)]\n    {\n        std::os::windows::fs::symlink_file(target, link)\n    }\n    #[cfg(unix)]\n    {\n        std::os::unix::fs::symlink(target, link)\n    }\n    #[cfg(not(any(unix, windows)))]\n    {\n        let _ = (target, link);\n        Err(std::io::Error::new(\n            std::io::ErrorKind::Unsupported,\n            \"file symlinks are unsupported on this platform\",\n        ))\n    }\n}\n\nfn hash_tagged(tag: &[u8], content: &[u8]) -> String {\n    let mut digest = Sha256::new();\n    digest.update(tag);\n    digest.update([0]);\n    digest.update(content);\n    hex::encode(digest.finalize())\n}\n\nfn valid_operation_id(operation_id: &str) -> bool {\n    operation_id.len() == 16\n        && operation_id\n            .bytes()","sourceCodeStart":479,"sourceCodeEnd":515,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/tauri/src/service/profile_file.rs#L479-L515","documentation":"`create_file_symlink` in profile_file.rs provides symlink creation for unix and windows, but on any other target (cfg falls through) it returns an `Unsupported` io::Error stating file symlinks are unsupported. This is a compile-time platform gate: the code has no implementation for that platform.","triggerScenarios":"Calling `create_ready_link` (directly or via journal/cleanup or atomic-write paths) on a platform that is neither unix nor windows (e.g. wasm target), reaching the fallback branch of `create_file_symlink`.","commonSituations":"Cross-compiling the service for an exotic target, running profile-linking logic in a wasm/web environment, or porting the profile service to a new OS without adding a symlink implementation.","solutions":["Run only on supported platforms (unix/windows).","Add a platform-specific implementation or copy-based fallback in create_file_symlink for the new target.","Refactor callers to use a copy fallback when symlink support is absent."],"exampleFix":"// before\nErr(std::io::Error::new(ErrorKind::Unsupported, \"file symlinks are unsupported on this platform\"))\n// after\nstd::fs::copy(target, link).map_err(|e| std::io::Error::new(e.kind(), format!(\"symlink unsupported; copy fallback failed: {e}\")))","handlingStrategy":"fallback","validationCode":"if !(cfg!(unix) || cfg!(windows)) {\n    // use copy fallback instead of symlink\n}","typeGuard":null,"tryCatchPattern":"match create_file_symlink(target, link) {\n    Err(e) if e.kind() == std::io::ErrorKind::Unsupported => std::fs::copy(target, link)?,\n    other => other?,\n}","preventionTips":["Only target unix/windows platforms for the profile-link feature","Provide a copy fallback for unsupported targets","Gate symlink-dependent features behind a platform check at startup"],"tags":["filesystem","symlink","platform","unsupported"],"backgroundTag":"unsupported-platform","analyzedSha":"f7dbce2997c633e484f54788035e770b3ee99773","analyzedAt":"2026-09-08T01:24:59.197Z","contentChangedAt":"2026-09-08T01:24:59.197Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}