{"record":{"id":"1714219992ba1c56","repo":"sxyazi/yazi","slug":"unwinding-must-be-enabled-for-windows-please-use","errorCode":null,"errorMessage":"Unwinding must be enabled for Windows. Please use `cargo build --profile release-windows --locked` instead to build Yazi.","messagePattern":"Unwinding must be enabled for Windows\\. Please use `cargo build --profile release-windows --locked` instead to build Yazi\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"yazi-fm/build.rs","lineNumber":13,"sourceCode":"use std::{env, error::Error};\n\nfn main() -> Result<(), Box<dyn Error>> {\n\tlet dir = env::var(\"OUT_DIR\").unwrap();\n\n\t// cargo build\n\t//   C:\\Users\\Ika\\Desktop\\yazi\\target\\release\\build\\yazi-fm-cfc94820f71daa30\\out\n\t// cargo install\n\t//   C:\\Users\\Ika\\AppData\\Local\\Temp\\cargo-installTFU8cj\\release\\build\\\n\t// yazi-fm-45dffef2500eecd0\\out\n\n\tif dir.contains(r\"\\release\\build\\yazi-fm-\") {\n\t\tpanic!(\n\t\t\t\"Unwinding must be enabled for Windows. Please use `cargo build --profile release-windows --locked` instead to build Yazi.\"\n\t\t);\n\t}\n\n\tlet manifest = env::var_os(\"CARGO_MANIFEST_DIR\").unwrap().to_string_lossy().replace(r\"\\\", \"/\");\n\tif manifest.contains(\"/git/checkouts/yazi-\")\n\t\t|| manifest.contains(\"/registry/src/index.crates.io-\")\n\t{\n\t\tpanic!(\n\t\t\t\"Due to Cargo's limitations, Yazi on crates.io must be built with `cargo install --force yazi-build`\"\n\t\t);\n\t}\n\n\tOk(())\n}\n","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/sxyazi/yazi/blob/441b332de8b8800e70784cfbfb75369ab51ed9dd/yazi-fm/build.rs#L1-L29","documentation":"Thrown by the impl_into_number! macro in yazi-shared (yazi-shared/src/data/macros.rs:72) when converting a Data value to a numeric type whose conversion is lossy or of an unaccepted variant. The match arms carry round-trip guards: an Integer must satisfy `*i == *i as $b as i64`, a float must survive `f64::from(*n) == f64::from(*n) as $b as f64`, and an Id must fit the target; otherwise control falls to the bail. Non-numeric variants (Bool, Nil, List, Table) also land here.","triggerScenarios":"Passing a number that does not fit the target type (e.g. 300 or -1 to a u8-typed argument, a fractional value to an integer field with a lossy cast, NaN/Infinity); passing nil/boolean/table where the handler does get::<f64>/take::<u32>; an Id (u64) exceeding the target's range for signed targets.","commonSituations":"Config/plugin values out of range after a version change narrowed a field type; Lua integers exceeding 2^53 losing precision through f64; negative values sent to unsigned fields.","solutions":["Clamp or validate the value on the Lua side before emitting so it fits the Rust field's range","Check for nil/boolean and convert explicitly with tonumber() before passing","Log the delivered Data (YAZI_LOG=debug / ya.dbg) to identify which argument is out of range","If the field should accept the value, widen the Rust field type in the receiving form"],"exampleFix":"-- before\nya.emit(\"preview\", { ratio = 400 })  -- handler expects u8\n-- after\nya.emit(\"preview\", { ratio = math.min(400, 255) })","handlingStrategy":"validation","validationCode":"-- Lua: range-check before emitting\nlocal function clamp_u8(v) return math.max(0, math.min(255, math.floor(tonumber(v) or 0))) end","typeGuard":"-- Lua\nlocal function is_number(v)\n  local n = tonumber(v)\n  return n ~= nil and n == n and n ~= math.huge and n ~= -math.huge\nend","tryCatchPattern":"local ok, err = pcall(ya.emit, \"cmd\", { ratio = v })\nif not ok then ya.dbg(\"numeric arg rejected: \" .. tostring(err)) end","preventionTips":["Know each Rust field's integer width and clamp values on the Lua side","Reject NaN/Infinity before sending","Prefer integers in Lua (math.type == 'integer') to avoid f64 precision loss","Test boundary values (0, max, negative) when writing plugins"],"tags":["rust","lua","numeric-range","type-conversion","yazi"],"backgroundTag":"value-out-of-range","analyzedSha":"441b332de8b8800e70784cfbfb75369ab51ed9dd","analyzedAt":"2026-08-19T05:27:26.468Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}