{"record":{"id":"031a621d47efccba","repo":"zed-industries/zed","slug":"must-be-a-positive-normal-number-or-randr","errorCode":null,"errorMessage":"`{}` must be a positive normal number or `randr`. Got `{}`","messagePattern":"`(.+?)` must be a positive normal number or `randr`\\. Got `(.+?)`","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui_linux/src/linux/x11/client.rs","lineNumber":2572,"sourceCode":"}\n\nenum DpiMode {\n    Randr,\n    Scale(f32),\n    NotSet,\n}\n\nfn 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);","sourceCodeStart":2554,"sourceCodeEnd":2590,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/gpui_linux/src/linux/x11/client.rs#L2554-L2590","documentation":"When the GPUI_X11_SCALE_FACTOR environment variable parses as an f32, the value must pass valid_scale_factor — a positive, finite, normal number. Numeric-but-invalid values such as 0, negatives, NaN, or infinity fall through to this panic naming the variable and the bad value. Valid alternatives are any positive scale (e.g. 1.5) or the literal `randr` for automatic detection.","triggerScenarios":"Launching Zed with GPUI_X11_SCALE_FACTOR set to '0', '-2', 'inf', 'nan', or any non-positive numeric string.","commonSituations":"Scripts or dotfiles setting the variable from a computed value that produced 0 or a negative number; copy-pasted configs with a placeholder value.","solutions":["Set the variable to a positive scale factor, e.g. GPUI_X11_SCALE_FACTOR=1.5","Or set it to `randr` to derive the scale from the monitor","Or unset it / set it empty to use the default detection"],"exampleFix":"# before\nexport GPUI_X11_SCALE_FACTOR=0     # panic\n\n# after\nexport GPUI_X11_SCALE_FACTOR=1.5    # or: randr","handlingStrategy":"validation","validationCode":"# shell: validate before launch\nv=\"${GPUI_X11_SCALE_FACTOR:-}\"\n[ -z \"$v\" ] || [ \"$v\" = randr ] || awk -v x=\"$v\" 'BEGIN{exit !(x>0 && x==x)}' \\\n  || { echo \"bad GPUI_X11_SCALE_FACTOR: $v\"; exit 1; }","typeGuard":"fn valid_scale_env(v: &str) -> bool {\n    v.is_empty()\n        || v.eq_ignore_ascii_case(\"randr\")\n        || v.parse::<f32>().map(|s| s.is_normal() && s > 0.0).unwrap_or(false)\n}","tryCatchPattern":null,"preventionTips":["Set the variable only to a plain positive decimal (1.5) or `randr`","Never compute the value from something that can yield 0 or a negative number","Prefer leaving it unset and using per-monitor scaling settings"],"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-14T00:17:10.932Z"}