zed-industries/zed · error
`{}` must be a positive number or `randr`. Got `{}`
Error message
`{}` must be a positive number or `randr`. Got `{}` What it means
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.
Source
Thrown at crates/gpui_linux/src/linux/x11/client.rs:2580
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);
match env_dpi {
DpiMode::Scale(scale) => {
log::info!(
"Using scale factor from {}: {}",
GPUI_X11_SCALE_FACTOR_ENV,
scale
);View on GitHub (pinned to 9d272b0363)
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
Example fix
# before export GPUI_X11_SCALE_FACTOR=1,5x # panic # after export GPUI_X11_SCALE_FACTOR=1.5 # or: randr
Defensive patterns
Strategy: validation
Validate before calling
# shell: reject non-numeric values early
v="${GPUI_X11_SCALE_FACTOR:-}"
[ -z "$v" ] || [ "${v,,}" = randr ] || [[ "$v" =~ ^[0-9]+([.][0-9]+)?$ ]] \
|| { echo "GPUI_X11_SCALE_FACTOR must be a number or 'randr'"; exit 1; } Type guard
fn scale_env_is_wellformed(v: &str) -> bool {
v.is_empty() || v.eq_ignore_ascii_case("randr") || v.parse::<f32>().is_ok()
} Prevention
- 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'
When it happens
Trigger: 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.
Common situations: Copy-pasted config snippets with placeholders; locale-formatted numbers ('1,5'); typos like 'randrr'.
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 normal 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/f1a2040d69c43dfc.
Report an issue: GitHub.