zed-industries/zed · error · Error

Could not parse screen resolution

Error message

Could not parse screen resolution

What it means

On macOS, script/zed-local reads the main display's resolution from `system_profiler SPDisplaysDataType -json`, walks spdisplays_ndrvs for the entry flagged spdisplays_main, and regex-matches its _spdisplays_resolution string. This throw means that chain produced nothing matchable — no main-display entry, or a resolution string in a format RESOLUTION_REGEX doesn't accept.

Source

Thrown at script/zed-local:100

const platform = os.platform();

let screenWidth, screenHeight;
const titleBarHeight = 24;

if (platform === "darwin") {
  // macOS
  const displayInfo = JSON.parse(
    execFileSync("system_profiler", ["SPDisplaysDataType", "-json"], {
      encoding: "utf8",
    }),
  );
  const mainDisplayResolution = displayInfo?.SPDisplaysDataType?.flatMap(
    (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(

View on GitHub (pinned to bc538def45)

Solutions

  1. Run `system_profiler SPDisplaysDataType -json` and confirm spdisplays_ndrvs, spdisplays_main, and _spdisplays_resolution still appear with values
  2. Ensure the machine has an interactive GUI session with a main display
  3. Update RESOLUTION_REGEX or the key chain for the new format
  4. Run the window-layout script on a physical, logged-in Mac
Defensive patterns

Strategy: fallback

Try / catch

try {
  [screenWidth, screenHeight] = getMacScreenSize();
} catch (e) {
  console.warn(`${e.message}; falling back to 1440x900`);
  screenWidth = 1440;
  screenHeight = 900 - titleBarHeight;
}

Prevention

When it happens

Trigger: Running headless or over SSH with no attached main display; a macOS release that renames the underscore-prefixed system_profiler keys; display configurations where spdisplays_main is absent from every ndrvs entry.

Common situations: macOS CI VMs without display configuration; new macOS betas reshaping SPDisplays JSON; unusual multi-monitor setups.

Related errors


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