zed-industries/zed · error
`{}` must be a positive normal number or `randr`. Got `{}`
Error message
`{}` must be a positive normal number or `randr`. Got `{}` What it means
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.
Source
Thrown at crates/gpui_linux/src/linux/x11/client.rs:2572
}
enum DpiMode {
Randr,
Scale(f32),
NotSet,
}
fn get_scale_factor(
connection: &XCBConnection,
resource_database: &Database,
screen_index: usize,
) -> f32 {
let env_dpi = std::env::var(GPUI_X11_SCALE_FACTOR_ENV)
.ok()
.map(|var| {
if var.to_lowercase() == "randr" {
DpiMode::Randr
} else if let Ok(scale) = var.parse::<f32>() {
if valid_scale_factor(scale) {
DpiMode::Scale(scale)
} else {
panic!(
"`{}` must be a positive normal number or `randr`. Got `{}`",
GPUI_X11_SCALE_FACTOR_ENV, var
);
}
} else if var.is_empty() {
DpiMode::NotSet
} else {
panic!(
"`{}` must be a positive number or `randr`. Got `{}`",
GPUI_X11_SCALE_FACTOR_ENV, var
);
}
})
.unwrap_or(DpiMode::NotSet);View on GitHub (pinned to 9d272b0363)
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
Example fix
# before export GPUI_X11_SCALE_FACTOR=0 # panic # after export GPUI_X11_SCALE_FACTOR=1.5 # or: randr
Defensive patterns
Strategy: validation
Validate before calling
# shell: validate before launch
v="${GPUI_X11_SCALE_FACTOR:-}"
[ -z "$v" ] || [ "$v" = randr ] || awk -v x="$v" 'BEGIN{exit !(x>0 && x==x)}' \
|| { echo "bad GPUI_X11_SCALE_FACTOR: $v"; exit 1; } Type guard
fn valid_scale_env(v: &str) -> bool {
v.is_empty()
|| v.eq_ignore_ascii_case("randr")
|| v.parse::<f32>().map(|s| s.is_normal() && s > 0.0).unwrap_or(false)
} Prevention
- 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
When it happens
Trigger: Launching Zed with GPUI_X11_SCALE_FACTOR set to '0', '-2', 'inf', 'nan', or any non-positive numeric string.
Common situations: Scripts or dotfiles setting the variable from a computed value that produced 0 or a negative number; copy-pasted configs with a placeholder value.
Understand the failure class
Background: "is not a valid" / "Invalid ... value" environment variable errors: how libraries validate env vars and what to do when they reject yours — this error's family across 48 libraries.
Related errors
- `{}` must be a positive number or `randr`. Got `{}`
- X11 connection: File descriptor passing failed
- X11 connection: Insufficient memory
- blocking sender returned without value
- wl_seat below required version: {} < {}
AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20).
Data as JSON: /api/errors/031a621d47efccba.
Report an issue: GitHub.