{"record":{"id":"f1a2040d69c43dfc","repo":"zed-industries/zed","slug":"must-be-a-positive-number-or-randr-got","errorCode":null,"errorMessage":"`{}` must be a positive number or `randr`. Got `{}`","messagePattern":"`(.+?)` must be a positive number or `randr`\\. Got `(.+?)`","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui_linux/src/linux/x11/client.rs","lineNumber":2580,"sourceCode":"fn get_scale_factor(\n    connection: &XCBConnection,\n    resource_database: &Database,\n    screen_index: usize,\n) -> f32 {\n    let env_dpi = std::env::var(GPUI_X11_SCALE_FACTOR_ENV)\n        .ok()\n        .map(|var| {\n            if var.to_lowercase() == \"randr\" {\n                DpiMode::Randr\n            } else if let Ok(scale) = var.parse::<f32>() {\n                if valid_scale_factor(scale) {\n                    DpiMode::Scale(scale)\n                } else {\n                    panic!(\n                        \"`{}` must be a positive normal number or `randr`. Got `{}`\",\n                        GPUI_X11_SCALE_FACTOR_ENV, var\n                    );\n                }\n            } else if var.is_empty() {\n                DpiMode::NotSet\n            } else {\n                panic!(\n                    \"`{}` must be a positive number or `randr`. Got `{}`\",\n                    GPUI_X11_SCALE_FACTOR_ENV, var\n                );\n            }\n        })\n        .unwrap_or(DpiMode::NotSet);\n\n    match env_dpi {\n        DpiMode::Scale(scale) => {\n            log::info!(\n                \"Using scale factor from {}: {}\",\n                GPUI_X11_SCALE_FACTOR_ENV,\n                scale\n            );","sourceCodeStart":2562,"sourceCodeEnd":2598,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/gpui_linux/src/linux/x11/client.rs#L2562-L2598","documentation":"The other invalid-value branch for GPUI_X11_SCALE_FACTOR: the variable is not the literal `randr`, does not parse as an f32, and is not empty. Any malformed non-numeric string (e.g. 'auto', '1.5x', '1,5' with a comma) hits this panic naming the variable and the offending value.","triggerScenarios":"Launching with GPUI_X11_SCALE_FACTOR set to a non-numeric string other than `randr`, including values with unit suffixes, locale decimal commas, or stray whitespace/quotes.","commonSituations":"Copy-pasted config snippets with placeholders; locale-formatted numbers ('1,5'); typos like 'randrr'.","solutions":["Use a plain decimal number with a dot: GPUI_X11_SCALE_FACTOR=1.5","Use the exact literal `randr` (lowercase per the comparison, though the check is case-insensitive for 'randr') for automatic scaling","Unset the variable or set it empty to fall back to default detection"],"exampleFix":"# before\nexport GPUI_X11_SCALE_FACTOR=1,5x   # panic\n\n# after\nexport GPUI_X11_SCALE_FACTOR=1.5     # or: randr","handlingStrategy":"validation","validationCode":"# shell: reject non-numeric values early\nv=\"${GPUI_X11_SCALE_FACTOR:-}\"\n[ -z \"$v\" ] || [ \"${v,,}\" = randr ] || [[ \"$v\" =~ ^[0-9]+([.][0-9]+)?$ ]] \\\n  || { echo \"GPUI_X11_SCALE_FACTOR must be a number or 'randr'\"; exit 1; }","typeGuard":"fn scale_env_is_wellformed(v: &str) -> bool {\n    v.is_empty() || v.eq_ignore_ascii_case(\"randr\") || v.parse::<f32>().is_ok()\n}","tryCatchPattern":null,"preventionTips":["Use a dot as the decimal separator; no unit suffixes (1.5x) or commas (1,5)","Quote environment values in dotfiles exactly: GPUI_X11_SCALE_FACTOR=1.5","Unset the variable rather than setting placeholder text like 'auto'"],"tags":["zed","gpui","linux","x11","dpi","env-var","panic"],"backgroundTag":"invalid-env-var-value","analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}