Skip to content

Commit 0749395

Browse files
committed
Fix the desktop install shipping an empty node_modules
Reported from a real install: Error [ERR_MODULE_NOT_FOUND]: Cannot find package '@diskpush/database' imported from ~/.local/share/diskpush/app/resources/cli/dist/bin.js Two bugs compounding, neither visible in the artifact I checked. Node's `fs.cpSync` resolves relative symlinks to absolute paths unless `verbatimSymlinks` is set. Copying the staged CLI into the app therefore rewrote pnpm's good `../.pnpm/...` links as absolute paths into this script's temp directory - which the same script deletes in its finally block. The links were dangling before packaging even started. electron-builder's extraResources copy then silently produced nothing for those broken links, so the shipped app had `resources/cli/node_modules` present but empty. The CLI-only tarball was unaffected: tar preserved the relative links, which is why that path installed and ran fine and this went unnoticed. Fixed at the root rather than by repairing the links: the deploy now uses `--config.node-linker=hoisted`, so the bundle is plain directories with zero symlinks - same 33MB - and survives any copy, including whatever electron-builder does to it. `verbatimSymlinks: true` is set as well so the copy cannot reintroduce the problem.
1 parent 26e8239 commit 0749395

2 files changed

Lines changed: 18 additions & 4 deletions

File tree

‎apps/web/components/chrome.tsx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ function Logo() {
6666
alt="DiskPush"
6767
width={2172}
6868
height={724}
69-
className="logo-dark h-14 w-auto"
69+
className="logo-dark w-60 h-auto"
7070
/>
71-
<img src="/logo.png" alt="DiskPush" width={2172} height={724} className="logo-light h-14 w-auto" />
71+
<img src="/logo.png" alt="DiskPush" width={2172} height={724} className="logo-light w-60 h-auto" />
7272
</>
7373
)
7474
}

‎scripts/package-cli.mjs‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,18 @@ try {
7777
const stage = join(work, 'cli')
7878
// --legacy because these are ordinary workspace links rather than injected
7979
// dependencies; --prod so devDependencies stay out of the artifact.
80-
run('pnpm', ['deploy', '--filter', '@diskpush/cli', '--prod', '--legacy', stage], checkout)
80+
//
81+
// node-linker=hoisted is load-bearing. pnpm's default layout links each
82+
// package from node_modules/.pnpm, and those symlinks do not survive the
83+
// trip into an Electron bundle: electron-builder's extraResources copy drops
84+
// them, and the app ships an empty node_modules that fails at first run with
85+
// "Cannot find package '@diskpush/database'". A hoisted tree is plain
86+
// directories, the same 33MB, and survives any copy.
87+
run(
88+
'pnpm',
89+
['deploy', '--filter', '@diskpush/cli', '--prod', '--legacy', '--config.node-linker=hoisted', stage],
90+
checkout,
91+
)
8192

8293
writeFileSync(join(stage, 'diskpush'), LAUNCHER, { mode: 0o755 })
8394

@@ -88,7 +99,10 @@ try {
8899
// The desktop build embeds this same tree, so both surfaces ship one build.
89100
const embedded = join(root, 'apps/desktop/resources/cli')
90101
rmSync(embedded, { recursive: true, force: true })
91-
cpSync(stage, embedded, { recursive: true })
102+
// verbatimSymlinks: without it Node's cp resolves relative symlinks to
103+
// absolute paths, which would point into this script's temp directory - the
104+
// one deleted in the finally block below.
105+
cpSync(stage, embedded, { recursive: true, verbatimSymlinks: true })
92106
console.log(`embedded a copy at ${embedded}`)
93107

94108
console.log(`\n${join(outDir, `${name}.tar.gz`)}`)

0 commit comments

Comments
 (0)