{"record":{"id":"7f6f7578847b9d4b","repo":"tracel-ai/burn","slug":"unsupported-target-os-os","errorCode":null,"errorMessage":"unsupported TARGET_OS '{os}'","messagePattern":"unsupported TARGET_OS '(.+?)'","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/burn-tch/build.rs","lineNumber":53,"sourceCode":"    libtorch_include_dirs: Vec<PathBuf>,\n    libtorch_lib_dir: PathBuf,\n}\n\nfn env_var_rerun(name: &str) -> Result<String, env::VarError> {\n    println!(\"cargo:rerun-if-env-changed={name}\");\n    env::var(name)\n}\n\nimpl SystemInfo {\n    fn new() -> Option<Self> {\n        let os = match env::var(\"CARGO_CFG_TARGET_OS\")\n            .expect(\"Unable to get TARGET_OS\")\n            .as_str()\n        {\n            \"linux\" => Os::Linux,\n            \"windows\" => Os::Windows,\n            \"macos\" => Os::Macos,\n            os => panic!(\"unsupported TARGET_OS '{os}'\"),\n        };\n        // Locate the currently active Python binary, similar to:\n        // https://github.com/PyO3/maturin/blob/243b8ec91d07113f97a6fe74d9b2dcb88086e0eb/src/target.rs#L547\n        let python_interpreter = match os {\n            Os::Windows => PathBuf::from(\"python.exe\"),\n            Os::Linux | Os::Macos => {\n                if env::var_os(\"VIRTUAL_ENV\").is_some() {\n                    PathBuf::from(\"python\")\n                } else {\n                    PathBuf::from(\"python3\")\n                }\n            }\n        };\n        let mut libtorch_include_dirs = vec![];\n        let mut libtorch_lib_dir = None;\n        let cxx11_abi = if env_var_rerun(\"LIBTORCH_USE_PYTORCH\").is_ok() {\n            let output = std::process::Command::new(&python_interpreter)\n                .arg(\"-c\")","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/tracel-ai/burn/blob/d16f7ba2ed0d41408189384044cc886fb4c8f957/crates/burn-tch/build.rs#L35-L71","documentation":"burn-tch's build script recognizes only linux, windows, and macos as TARGET_OS values when locating libtorch and configuring the tch bindings. If the cargo-provided TARGET_OS environment variable holds anything else (or is malformed), the build script panics, failing compilation of the burn-tch crate.","triggerScenarios":"Building burn-tch for a target platform outside {linux, windows, macos} — e.g. freebsd, android, wasm, or a custom/nightly target triple whose OS string is unexpected; or an environment where TARGET_OS is unset/overridden by a wrapper script.","commonSituations":"Cross-compiling burn with the tch backend to embedded/mobile targets; building in nonstandard CI containers that clobber cargo metadata env vars; typos in `--target` triples via cargo build --target=<os-specific-string>.","solutions":["Build for a supported OS (linux, windows, macos); use another backend (libtorch via burn-core with a different backend, candle, ndarray) for unsupported targets.","Check `echo $TARGET_OS` in the failing build environment and remove any override of cargo's TARGET_OS.","If you must target another OS, patch the build script's match to add the Os variant and provide libtorch paths manually."],"exampleFix":"// before\ncargo build --target=x86_64-unknown-freebsd --features tch   // panics: unsupported TARGET_OS 'freebsd'\n// after\ncargo build --target=x86_64-unknown-linux-gnu --features tch  // or use the candle/ndarray backend","handlingStrategy":"validation","validationCode":"# fail fast before cargo build\nimport subprocess, os, sys\ntarget_os = os.environ.get(\"CARGO_CFG_TARGET_OS\", \"\")\nif target_os not in (\"linux\", \"windows\", \"macos\") and \"tch\" in sys.argv:\n    sys.exit(f\"burn-tch does not support TARGET_OS '{target_os}'\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only enable the tch feature on linux/windows/macos targets","Use cfg-based Cargo features to pick backends per target","Don't override cargo's TARGET_OS/CARGO_CFG_TARGET_OS env vars in CI"],"tags":["rust","build-script","platform","tch"],"backgroundTag":"unsupported-target-platform","analyzedSha":"d16f7ba2ed0d41408189384044cc886fb4c8f957","analyzedAt":"2026-09-05T13:19:14.260Z","contentChangedAt":"2026-09-05T13:19:14.260Z","schemaVersion":2},"datasetVersion":"2026-09-12T17:17:11.597Z"}