·5 min read
DailyBrief only worked on my disk, so I split install from per-user data
The packaged DailyBrief exe worked on exactly one computer: mine. Its main.js held an absolute path into my own OneDrive desktop, and so did the scripts it launched. Install it anywhere else and it found nothing. Install it for a second Windows user on the same machine and, in the words of the commit, it "would have shown them someone else's day". That commit, dfd8ecd, is where I split one folder into two.
- Project
- DailyBrief
- Date
- Aug 2026
- Stack
- Electron, PowerShell, Node.js, SQLite
- Commit
- dfd8ecd
Two bugs hiding as one
When I read the old main.js again, there were two separate design mistakes in it, and the hardcoded path was only the visible one.
The visible one was this:
const ROOT = app.isPackaged
? 'C:\\Users\\<user>\\OneDrive\\Desktop\\DailyBriefApp'
: __dirname;The comment above it explained the intent: the exe ran from output\win-unpacked, but the live project stayed at the project root "so Claude's daily edits keep reaching the running app". That sentence is the second mistake. The daily pipeline did not just produce data. It spliced the new plan into brief-app.html, the page itself, and the app reloaded when that file changed. Code, data and the running UI were one tangled thing, and it only worked because the author and the user were the same person on the same disk.
Two roots
The replacement starts with a comment I wrote to keep myself honest, because the two roots look alike and must never be mixed:
const APP_ROOT = app.isPackaged ? process.resourcesPath : __dirname;
const CORE_DIR = path.join(APP_ROOT, 'core');
const DATA = process.env.DAILYBRIEF_DATA
|| (app.isPackaged ? path.join(app.getPath('userData'), 'data') : CORE_DIR);APP_ROOT is what the installer put on disk: the page, the icon, and the core\*.ps1 scripts with their prompts. It is shared by everyone on the machine and never written to at runtime. DATA is one folder per Windows account: briefs, the kanban board, the SQLite file, run logs. Two people on one PC cannot see each other's day, because their userData folders are different.
Two details here matter. A packaged build keeps core\ outside the asar archive, through electron-builder's extraResources, because PowerShell cannot execute a script that lives inside an asar. The page, on the other hand, ships inside the asar, so it is addressed from app.getAppPath() and not from resourcesPath. Getting those two backwards gives you a window that opens blank or a script that cannot start, and the difference is a single path join.
The other detail is the override. In development DATA falls back to CORE_DIR, so a checked-out repo keeps its data in core\ exactly as before, and DAILYBRIEF_DATA can point anywhere.
Making the scripts agree
The PowerShell side has to resolve the same two places without asking Electron. I put that in one small file, core/paths.ps1:
$app = $PSScriptRoot
$base = if ($env:DAILYBRIEF_DATA) { $env:DAILYBRIEF_DATA } else { $PSScriptRoot }
if (-not (Test-Path $base)) { New-Item -ItemType Directory -Force $base | Out-Null }main.js decides the data location once and sets DAILYBRIEF_DATA before it spawns any script, so there is exactly one source of truth. Run a script by hand without the variable and $base is the script folder, which is what a checkout wants. The file is ASCII-only on purpose, with a note that this is for PowerShell 5.1 encoding. That is the same family of trouble that produced my mojibake repair, and I did not want to meet it again in the file that every script loads first.
Stop editing the page
The second mistake needed its own fix. The pipeline no longer touches the page. Briefs were already readable over IPC from briefs/<date>.json, so the splice into the HTML was removed and the inline BRIEF block became an empty placeholder. Publishing a web copy of a brief is now opt-in, configured through a publish.json, and it renders its own standalone page instead of reusing the app's. After this change the install directory is genuinely read-only at runtime, which is what makes the shared-install idea safe.
Migration without destroying anything
Existing data had to move. On the first packaged run, the app migrates data from an older in-project folder and leaves the old one in place as a backup. The check is by folder shape, not by user name, so it does nothing on a machine that never ran an older build. I will say honestly that this function had a bug on its first release: copying into a destination that did not exist threw ENOENT inside a catch that swallowed it. It took a follow-up fix, c452d06, to create the folder first and seed the files the scripts read unconditionally. The original idea was sound, but I shipped it without testing the fresh-account path.
The pieces that came along
A change like this is a good moment to pay other debts, and the commit message lists them. Run files are pruned to the newest 20 per family instead of growing forever. The renderer declares a content security policy that blocks all network access. The pure logic moved out of main.js into src/ with unit tests (text, prune, zoom) and a CI workflow that runs them plus a packaged build. And the electron-builder file list now ships the page, src/ and core/, which it had been leaving out. That last one is a good example of why a packaged build needs to be run somewhere other than the dev machine: on my disk the missing files were found through the hardcoded path, so nothing ever complained.
What I took from it
The test for whether an app is really installed is not that it starts. It is whether it starts on a machine that has none of your files, for a user that is not you. Splitting code from data gave me three things at once: a second user's data is separate by construction, the install folder never changes after install, and a script launched by hand still behaves. The cost was one environment variable and a 15-line file. I should have drawn the line between the two roots on the first day, when the hardcoded path was still a convenience and not a trap.
#electron#packaging#powershell#architecture
Keep reading
Have a project in mind?