From 3ebe0f445db400df670ee5dbd13c404a15cf53fe Mon Sep 17 00:00:00 2001 From: Jack Amadeo Date: Fri, 3 Apr 2026 10:33:34 -0400 Subject: [PATCH] don't crash the app on a bad .json --- ui/desktop/src/distro.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/ui/desktop/src/distro.ts b/ui/desktop/src/distro.ts index 173b650125..ba4ee51d52 100644 --- a/ui/desktop/src/distro.ts +++ b/ui/desktop/src/distro.ts @@ -27,13 +27,19 @@ function findDistroDir(): string | null { // Executes on import — must be imported before anything that reads process.env distroDir = findDistroDir(); if (distroDir) { - const configPath = path.join(distroDir, 'distro.json'); - distroConfig = JSON.parse(fs.readFileSync(configPath, 'utf-8')); + try { + const configPath = path.join(distroDir, 'distro.json'); + distroConfig = JSON.parse(fs.readFileSync(configPath, 'utf-8')); - if (distroConfig.env) { - for (const [key, value] of Object.entries(distroConfig.env)) { - process.env[key] = value; + if (distroConfig.env) { + for (const [key, value] of Object.entries(distroConfig.env)) { + process.env[key] = value; + } } + } catch (err) { + console.error('Failed to load distro.json, falling back to stock defaults:', err); + distroDir = null; + distroConfig = {}; } }