{"record":{"id":"a8b3e18851b99ed0","repo":"libnyanpasu/clash-nyanpasu","slug":"runtime-path-is-not-utf-8","errorCode":null,"errorMessage":"runtime path is not UTF-8: {}","messagePattern":"runtime path is not UTF-8: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"backend/tauri/src/client/runtime.rs","lineNumber":304,"sourceCode":"fn is_symlink_or_reparse(metadata: &std::fs::Metadata) -> bool {\n    metadata.file_type().is_symlink()\n}\n\n#[cfg(windows)]\nfn is_symlink_or_reparse(metadata: &std::fs::Metadata) -> bool {\n    use std::os::windows::fs::MetadataExt;\n    const FILE_ATTRIBUTE_REPARSE_POINT: u32 = 0x400;\n    metadata.file_attributes() & FILE_ATTRIBUTE_REPARSE_POINT != 0\n}\n\n#[cfg(not(any(unix, windows)))]\nfn is_symlink_or_reparse(metadata: &std::fs::Metadata) -> bool {\n    metadata.file_type().is_symlink()\n}\n\nfn utf8_path(path: std::path::PathBuf) -> anyhow::Result<Utf8PathBuf> {\n    Utf8PathBuf::from_path_buf(path)\n        .map_err(|path| anyhow::anyhow!(\"runtime path is not UTF-8: {}\", path.display()))\n}\n\n/// Public mutation wire (PR-4S S08 / plan §12): state is committed first; post-\n/// commit side-effect failures degrade instead of erroring.\n///\n/// Final wire is only `applied` / `committed_degraded` — no `_v1` alias.\n#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, specta::Type)]\n#[serde(tag = \"status\", rename_all = \"snake_case\")]\npub enum MutationOutcome<T> {\n    Applied {\n        value: T,\n    },\n    CommittedDegraded {\n        value: T,\n        degradations: Vec<Degradation>,\n    },\n}\n","sourceCodeStart":286,"sourceCodeEnd":322,"githubUrl":"https://github.com/libnyanpasu/clash-nyanpasu/blob/f7dbce2997c633e484f54788035e770b3ee99773/backend/tauri/src/client/runtime.rs#L286-L322","documentation":"`RuntimePaths::utf8_path` fails when a runtime-related path (config dir, product file, etc.) cannot be represented as `Utf8PathBuf`, i.e. it contains non-UTF-8 bytes. `RuntimePaths::from_resolver` requires UTF-8 paths since they flow into typed, serializable structures.","triggerScenarios":"Building `RuntimePaths::from_resolver` (backend/tauri/src/client/runtime.rs:304) when the OS-resolved runtime directory or file name contains non-UTF-8 bytes — typically a non-UTF-8 user home or data directory.","commonSituations":"Linux systems where `$HOME` or XDG data dirs contain legacy-encoded bytes; Windows profiles with unpaired surrogate characters; portable installs placed in a non-UTF-8 folder name.","solutions":["Move the app data/runtime directory to a path containing only valid UTF-8 characters","Fix the environment variables (HOME/XDG_CONFIG_HOME and equivalents) that resolve to the non-UTF-8 path","Identify the offending component with `path.to_str()` / `to_string_lossy` and rename it","On Windows, use UTF-8-safe APIs when choosing the install/data location"],"exampleFix":"// before\nexport HOME=\"/home/$(printf '\\xff\\xfe')\" # non-UTF-8 home breaks path resolution\n./nyanpasu\n// after\nexport HOME=\"/home/user\" # ensure UTF-8-safe directories\n./nyanpasu","handlingStrategy":"validation","validationCode":"fn ensure_utf8(path: &std::path::Path) -> Result<(), String> {\n    if path.to_str().is_some() { Ok(()) } else { Err(format!(\"non-UTF-8 runtime path: {:?}\", path.as_os_str())) }\n}\n// run on the resolver output before building RuntimePaths","typeGuard":"fn is_utf8_path(path: &std::path::Path) -> bool {\n    path.to_str().is_some()\n}","tryCatchPattern":null,"preventionTips":["Install the app in a UTF-8-safe directory (ASCII is safest)","Verify HOME/XDG env vars resolve to UTF-8 paths before startup","On Linux, run under a UTF-8 locale","Surface a friendly startup check that fails early with a clear message when the data dir is not UTF-8"],"tags":["path","encoding","utf-8","runtime"],"backgroundTag":"invalid-argument-value","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"}