Experience
Projects
My Stack
Case studies
Contact me
Open my CV

·5 min read

The app blamed the claude CLI, but my migration had swallowed an ENOENT

The app told me "claude CLI wrote no log". It was the one component in the chain that was working. The real failure happened earlier, in a PowerShell script that died on its first line of file I/O, before any log existed to write to. This is how a fresh account of DailyBrief 1.7.0 ended up with an error message pointing at the wrong suspect.

Project
DailyBrief
Date
Aug 2026
Stack
Electron, PowerShell, Node.js
Commit
c452d06

What 1.7.0 changed

Earlier builds of DailyBrief kept their data inside the project folder. 1.7.0 moved it to a per-user data folder, and main.js gained a migrateLegacyData() function. If an old folder exists and the new one is still empty, it copies the data across once. Nothing is deleted, the old folder stays as its own backup.

The part that mattered was the shape of the function. It looked for the legacy folders under the user's home, checked whether kanban.json already existed in the new location, and copied files over. The whole copy sat inside a try, with this at the end:

js
} catch (e) { /* a partial copy still beats starting empty */ }

That comment is reasonable for a copy that fails halfway through a large folder. It is a bad fit for a copy that fails on the first file.

The destination did not exist

ensureDataDirs() creates the data folder and its subfolders, but in the startup order it ran after migrateLegacyData():

js
if (app.isPackaged) migrateLegacyData();
ensureDataDirs();

So on the first launch of 1.7.0 the destination folder had not been created when the migration tried to copy into it. The copy threw ENOENT, the catch swallowed it, and the app carried on with a data folder that was created a moment later by ensureDataDirs(), now empty. From the outside it looked like a normal fresh install. For someone upgrading, it looked like their board was gone.

The only visible signal was downstream.

Where the symptom showed up

Each run starts a PowerShell script. Those scripts read a few files unconditionally: kanban.json in kanban-check.ps1, and dirs.txt in daily-brief.ps1. With an empty data folder both reads failed:

powershell
$kanban = Get-Content $kanbanPath -Raw -Encoding UTF8 | ConvertFrom-Json

Get-Content on a path that does not exist is a terminating problem for the script in this setup, and it happened before the script had opened its log file. The Electron side then watched for the log, found none, and reported "claude CLI wrote no log". That message pointed at the one component that was working. Anyone debugging from the message would start in the wrong place.

The lesson I took from this is about error messages that describe the last thing observed rather than the first thing that went wrong. "No log" is a fact about the log. It says nothing about why.

The three changes

The commit does three things, so that both a migrated account and a genuinely new one start cleanly.

First, the migration creates the destination before it copies:

js
function migrateLegacyData() {
  try { fs.mkdirSync(DATA, { recursive: true }); } catch (e) { return; }
  if (fs.existsSync(path.join(DATA, 'kanban.json'))) return;
  ...

Second, the first run seeds every file the scripts read unconditionally, and only when the file is absent, so a seed never overwrites migrated or working data:

js
const SEED_FILES = [
  ['kanban.json', JSON.stringify({ tasks: [], archive: [] }, null, 2)],
  ['dirs.txt', ''],
  ['GOALS.md', ''],
  ['STATE.md', ''],
  ['PROGRESS.md', '']
];

Third, the scripts stopped assuming the files exist. kanban-check.ps1 now treats a missing board as an empty board, and treats an unreadable one as a real error that goes into its log:

powershell
try {
    $kanban = Get-Content $kanbanPath -Raw -Encoding UTF8 | ConvertFrom-Json
} catch {
    [IO.File]::WriteAllText($log, ('[fatal] kanban.json unreadable: ' + $_.Exception.Message), $utf8NoBom)
    exit 4
}
if (-not $kanban) { $kanban = [pscustomobject]@{ tasks = @(); archive = @() } }

daily-brief.ps1 does the same for dirs.txt: no file means no watched folders, so the snapshot is empty and the day is planned without it, instead of the run failing.

Why three layers

It would have been enough to fix the mkdir order. I added the seeding and the script-side tolerance because the first fix only repairs the bug I had found. A user whose home folder is locked down, a disk that fills during the copy, or a future change to the startup order can all leave the data folder in a state the migration did not expect. An empty board is a normal state for a new account, so the scripts should handle it. An unreadable board is not normal, and it now writes a line to the log naming the file, which is exactly what was missing the first time.

The rule I applied afterwards: a catch that swallows an error needs a reason written next to it, and the reason has to still hold when the very first operation is the one that fails. Here the comment said a partial copy beats nothing. It never considered a copy that produced nothing at all.

#electron#powershell#error-handling#migration#debugging

Keep reading

Have a project in mind?