{"record":{"id":"489548210c08c8b8","repo":"zed-industries/zed","slug":"could-not-parse-screen-resolution","errorCode":null,"errorMessage":"Could not parse screen resolution","messagePattern":"Could not parse screen resolution","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"script/zed-local","lineNumber":100,"sourceCode":"const platform = os.platform();\n\nlet screenWidth, screenHeight;\nconst titleBarHeight = 24;\n\nif (platform === \"darwin\") {\n  // macOS\n  const displayInfo = JSON.parse(\n    execFileSync(\"system_profiler\", [\"SPDisplaysDataType\", \"-json\"], {\n      encoding: \"utf8\",\n    }),\n  );\n  const mainDisplayResolution = displayInfo?.SPDisplaysDataType?.flatMap(\n    (display) => display?.spdisplays_ndrvs,\n  )\n    ?.find((entry) => entry?.spdisplays_main === \"spdisplays_yes\")\n    ?._spdisplays_resolution?.match(RESOLUTION_REGEX);\n  if (!mainDisplayResolution) {\n    throw new Error(\"Could not parse screen resolution\");\n  }\n  screenWidth = parseInt(mainDisplayResolution[1]);\n  screenHeight = parseInt(mainDisplayResolution[2]) - titleBarHeight;\n} else if (platform === \"linux\") {\n  // Linux\n  try {\n    const xrandrOutput = execSync('xrandr | grep \"\\\\*\" | cut -d\" \" -f4', {\n      encoding: \"utf8\",\n    }).trim();\n    [screenWidth, screenHeight] = xrandrOutput.split(\"x\").map(Number);\n  } catch (err) {\n    console.log(err);\n    throw new Error(\"Could not get screen resolution\");\n  }\n} else if (platform === \"win32\") {\n  // windows\n  try {\n    const resolutionOutput = execSync(","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/zed-industries/zed/blob/bc538def4545534201bbfcac4e95ac34ea6501b6/script/zed-local#L82-L118","documentation":"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.","triggerScenarios":"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.","commonSituations":"macOS CI VMs without display configuration; new macOS betas reshaping SPDisplays JSON; unusual multi-monitor setups.","solutions":["Run `system_profiler SPDisplaysDataType -json` and confirm spdisplays_ndrvs, spdisplays_main, and _spdisplays_resolution still appear with values","Ensure the machine has an interactive GUI session with a main display","Update RESOLUTION_REGEX or the key chain for the new format","Run the window-layout script on a physical, logged-in Mac"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  [screenWidth, screenHeight] = getMacScreenSize();\n} catch (e) {\n  console.warn(`${e.message}; falling back to 1440x900`);\n  screenWidth = 1440;\n  screenHeight = 900 - titleBarHeight;\n}","preventionTips":["Smoke-test the system_profiler pipeline on each new macOS version before scripting against it","Run window-layout scripts from an interactive GUI session","Log the parsed system_profiler JSON once to catch key renames early"],"tags":["macos","display","system-profiler","script"],"backgroundTag":null,"analyzedSha":"bc538def4545534201bbfcac4e95ac34ea6501b6","analyzedAt":"2026-08-16T07:30:46.435Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}