tracel-ai/burn · error
unsupported TARGET_OS '{os}'
Error message
unsupported TARGET_OS '{os}' What it means
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.
Source
Thrown at crates/burn-tch/build.rs:53
libtorch_include_dirs: Vec<PathBuf>,
libtorch_lib_dir: PathBuf,
}
fn env_var_rerun(name: &str) -> Result<String, env::VarError> {
println!("cargo:rerun-if-env-changed={name}");
env::var(name)
}
impl SystemInfo {
fn new() -> Option<Self> {
let os = match env::var("CARGO_CFG_TARGET_OS")
.expect("Unable to get TARGET_OS")
.as_str()
{
"linux" => Os::Linux,
"windows" => Os::Windows,
"macos" => Os::Macos,
os => panic!("unsupported TARGET_OS '{os}'"),
};
// Locate the currently active Python binary, similar to:
// https://github.com/PyO3/maturin/blob/243b8ec91d07113f97a6fe74d9b2dcb88086e0eb/src/target.rs#L547
let python_interpreter = match os {
Os::Windows => PathBuf::from("python.exe"),
Os::Linux | Os::Macos => {
if env::var_os("VIRTUAL_ENV").is_some() {
PathBuf::from("python")
} else {
PathBuf::from("python3")
}
}
};
let mut libtorch_include_dirs = vec![];
let mut libtorch_lib_dir = None;
let cxx11_abi = if env_var_rerun("LIBTORCH_USE_PYTORCH").is_ok() {
let output = std::process::Command::new(&python_interpreter)
.arg("-c")View on GitHub (pinned to d16f7ba2ed)
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.
Example fix
// before cargo build --target=x86_64-unknown-freebsd --features tch // panics: unsupported TARGET_OS 'freebsd' // after cargo build --target=x86_64-unknown-linux-gnu --features tch // or use the candle/ndarray backend
Defensive patterns
Strategy: validation
Validate before calling
# fail fast before cargo build
import subprocess, os, sys
target_os = os.environ.get("CARGO_CFG_TARGET_OS", "")
if target_os not in ("linux", "windows", "macos") and "tch" in sys.argv:
sys.exit(f"burn-tch does not support TARGET_OS '{target_os}'") Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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>.
Related errors
- no cxx11 abi returned by python {output:?}
- nearest exact interpolation is not supported by PyTorch/tch
- lanczos3 interpolation is not supported by PyTorch/tch backe
- nearest exact interpolation backward is not supported by PyT
- lanczos3 interpolation backward is not supported by PyTorch/
AI-assisted analysis of tracel-ai/burn@d16f7ba2ed (2026-09-05).
Data as JSON: /api/errors/7f6f7578847b9d4b.
Report an issue: GitHub.