{"record":{"id":"14c0c1f558ceb610","repo":"PyO3/pyo3","slug":"pyo3-cross-lib-dir-variable-value-is-not-a-valid-u","errorCode":null,"errorMessage":"PYO3_CROSS_LIB_DIR variable value is not a valid UTF-8 string","messagePattern":"PYO3_CROSS_LIB_DIR variable value is not a valid UTF-8 string","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pyo3-build-config/src/impl_.rs","lineNumber":1788,"sourceCode":"                    .ok_or(\"PYO3_CROSS_PYTHON_IMPLEMENTATION is not valid a UTF-8 string\")?;\n                utf8_str\n                    .parse()\n                    .context(\"failed to parse PYO3_CROSS_PYTHON_IMPLEMENTATION\")\n            })\n            .transpose()?;\n\n        Ok(implementation)\n    }\n\n    /// Converts the stored `PYO3_CROSS_LIB_DIR` variable value (if any)\n    /// into a `PathBuf` instance.\n    ///\n    /// Ensures that the path is a valid UTF-8 string.\n    fn lib_dir_path(&self) -> Result<Option<PathBuf>> {\n        let lib_dir = self.pyo3_cross_lib_dir.as_ref().map(PathBuf::from);\n\n        if let Some(dir) = lib_dir.as_ref() {\n            ensure!(\n                dir.to_str().is_some(),\n                \"PYO3_CROSS_LIB_DIR variable value is not a valid UTF-8 string\"\n            );\n        }\n\n        Ok(lib_dir)\n    }\n}\n\n/// Detect whether we are cross compiling and return an assembled CrossCompileConfig if so.\n///\n/// This function relies on PyO3 cross-compiling environment variables:\n///\n/// * `PYO3_CROSS`: If present, forces PyO3 to configure as a cross-compilation.\n/// * `PYO3_CROSS_LIB_DIR`: If present, must be set to the directory containing\n///   the target's libpython DSO and the associated `_sysconfigdata*.py` file for\n///   Unix-like targets, or the Python DLL import libraries for the Windows target.\n/// * `PYO3_CROSS_PYTHON_VERSION`: Major and minor version (e.g. 3.9) of the target Python","sourceCodeStart":1770,"sourceCodeEnd":1806,"githubUrl":"https://github.com/PyO3/pyo3/blob/ac9b6899d348be4d54614d060dea53a645a12e36/pyo3-build-config/src/impl_.rs#L1770-L1806","documentation":"Error while converting the PYO3_CROSS_LIB_DIR environment variable to a PathBuf via into_path_buf: on this platform the variable's raw bytes are not valid UTF-8, and the build config requires paths to be UTF-8 representable before it can use the cross lib directory.","triggerScenarios":"Thrown at pyo3-build-config/src/impl_.rs:1788 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-set PYO3_CROSS_LIB_DIR with a plain ASCII/UTF-8 path, avoiding locale-specific byte sequences","Quote the variable in CI scripts so it is not mangled by the shell","On Windows, avoid non-ANSI characters in the cross lib directory path"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ac9b6899d348be4d54614d060dea53a645a12e36","analyzedAt":"2026-09-05T09:20:35.319Z","contentChangedAt":"2026-09-05T09:20:35.319Z","schemaVersion":2},"datasetVersion":"2026-09-12T12:17:11.808Z"}