zed-industries/zed · error · Error

Could not get screen resolution

Error message

Could not get screen resolution

What it means

On Linux, script/zed-local shells out to `xrandr | grep "*" | cut -d" " -f4` to read the active mode; any failure in that pipeline (xrandr missing, no '*' mode line, grep exiting 1) lands in the catch block and is rethrown as this error.

Source

Thrown at script/zed-local:113

    (display) => display?.spdisplays_ndrvs,
  )
    ?.find((entry) => entry?.spdisplays_main === "spdisplays_yes")
    ?._spdisplays_resolution?.match(RESOLUTION_REGEX);
  if (!mainDisplayResolution) {
    throw new Error("Could not parse screen resolution");
  }
  screenWidth = parseInt(mainDisplayResolution[1]);
  screenHeight = parseInt(mainDisplayResolution[2]) - titleBarHeight;
} else if (platform === "linux") {
  // Linux
  try {
    const xrandrOutput = execSync('xrandr | grep "\\*" | cut -d" " -f4', {
      encoding: "utf8",
    }).trim();
    [screenWidth, screenHeight] = xrandrOutput.split("x").map(Number);
  } catch (err) {
    console.log(err);
    throw new Error("Could not get screen resolution");
  }
} else if (platform === "win32") {
  // windows
  try {
    const resolutionOutput = execSync(
      `powershell -Command "& {Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Screen]::PrimaryScreen.WorkingArea.Size}"`,
      { encoding: "utf8" },
    ).trim();
    [screenWidth, screenHeight] = resolutionOutput.match(/\d+/g).map(Number);
  } catch (err) {
    console.log(err);
    throw new Error("Could not get screen resolution on Windows");
  }
}

if (platform !== "win32") {
  screenHeight -= titleBarHeight;
}

View on GitHub (pinned to bc538def45)

Solutions

  1. Install xrandr (Debian/Ubuntu: `sudo apt install x11-xserver-utils`)
  2. Run `xrandr` manually and confirm a '*' line exists whose 4th field is WxH
  3. Under Xvfb, pass an explicit geometry: `xvfb-run -s "-screen 0 1920x1080x24"`
  4. On Wayland-only sessions, run via Xwayland or patch in an explicit size

Example fix

# before
xvfb-run node script/zed-local   # xrandr shows no '*' mode

# after
xvfb-run -s "-screen 0 1920x1080x24" node script/zed-local
Defensive patterns

Strategy: fallback

Validate before calling

const probe = execSync("xrandr --current", { encoding: "utf8" });
if (!/^\s*\d+x\d+.*\*/m.test(probe)) {
  console.error("no active xrandr mode — configure the screen or install x11-xserver-utils");
  process.exit(1);
}

Try / catch

try {
  [screenWidth, screenHeight] = xrandrOutput.split("x").map(Number);
} catch {
  console.warn("xrandr failed; defaulting to 1920x1080");
  [screenWidth, screenHeight] = [1920, 1080];
}

Prevention

When it happens

Trigger: xrandr not installed (x11-xserver-utils missing); running under bare Wayland with no Xwayland; an Xvfb session with no screen mode configured; output formatting where column 4 isn't the geometry.

Common situations: Minimal containers or devimages without X utilities; headless test boxes; distros whose xrandr column layout differs.

Related errors


AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16). Data as JSON: /api/errors/a4a2ba7a6f8e176d. Report an issue: GitHub.