{"record":{"id":"3288bf838a369706","repo":"getzola/zola","slug":"project-root-dir-is-not-valid-utf-8","errorCode":null,"errorMessage":"Project root dir is not valid UTF-8.","messagePattern":"Project root dir is not valid UTF-8\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/serve.rs","lineNumber":567,"sourceCode":"        config_file,\n        include_drafts,\n        store_html,\n        no_port_append,\n    )?;\n    let base_path = match constructed_base_url.splitn(4, '/').nth(3) {\n        Some(path) => format!(\"/{path}\"),\n        None => \"/\".to_string(),\n    };\n\n    messages::report_elapsed_time(start);\n\n    // Stop right there if we can't bind to the address\n    if (TcpListener::bind(bind_address)).is_err() {\n        return Err(anyhow!(\"Cannot start server on address {}.\", bind_address));\n    }\n\n    let config_path = PathBuf::from(config_file);\n    let root_dir_str = root_dir.to_str().expect(\"Project root dir is not valid UTF-8.\");\n\n    // An array of (path, WatchMode, RecursiveMode) where the path is watched for changes,\n    // the WatchMode value indicates whether this path must exist for zola serve to operate,\n    // and the RecursiveMode value indicates whether to watch nested directories.\n    let mut watch_this = vec![\n        // The first entry is ultimately to watch config.toml in a more robust manner on Linux when\n        // the file changes by way of a caching strategy used by editors such as vim.\n        // https://github.com/getzola/zola/issues/2266\n        (root_dir_str, WatchMode::Required, RecursiveMode::NonRecursive),\n        (\"content\", WatchMode::Required, RecursiveMode::Recursive),\n        (\"sass\", WatchMode::Condition(site.config.compile_sass), RecursiveMode::Recursive),\n        (\"static\", WatchMode::Optional, RecursiveMode::Recursive),\n        (\"templates\", WatchMode::Optional, RecursiveMode::Recursive),\n        (\"themes\", WatchMode::Condition(site.config.theme.is_some()), RecursiveMode::Recursive),\n    ];\n    watch_this.extend(\n        extra_watch_paths\n            .iter()","sourceCodeStart":549,"sourceCodeEnd":585,"githubUrl":"https://github.com/getzola/zola/blob/61d30828217957120309db657950224edf9707e2/src/cmd/serve.rs#L549-L585","documentation":"serve() converts the project root directory Path to a &str via to_str().expect(...) so it can be embedded in URLs and watch paths. The expect fires when the path contains bytes that are not valid UTF-8 (e.g. non-UTF8 filesystem names on Unix), meaning the dev server cannot represent the project location as a string and refuses to start rather than serving from a mis-encoded path.","triggerScenarios":"Thrown at src/cmd/serve.rs:567 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Rename the project directory so its full path contains only valid UTF-8 characters","Avoid non-ASCII or raw-byte characters in directory names on the affected filesystem","Return a proper anyhow error with the path's Debug representation instead of expect(), so the offending path is visible to the user"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"61d30828217957120309db657950224edf9707e2","analyzedAt":"2026-09-03T14:39:09.727Z","contentChangedAt":"2026-09-03T14:39:09.727Z","schemaVersion":2},"datasetVersion":"2026-09-10T17:17:09.494Z"}