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
- 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
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
- 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
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
- Could not get screen resolution
- Could not get screen resolution on Windows
- Could not auto-update because the required rsync utility was
- failed to mount: {:?}
- failed to copy app: {:?}
AI-assisted analysis of zed-industries/zed@bc538def45 (2026-08-16).
Data as JSON: /api/errors/489548210c08c8b8.
Report an issue: GitHub.