Skip to content

Commit aee4ac0

Browse files
nedtwiggclaude
andcommitted
dogfood:vscode: graceful message when VS Code locks the extension dir
`code --install-extension` installs by renaming the extension folder; on Windows a running VS Code keeps the old Dormouse extension's node-pty native modules loaded and locks that folder, so the rename fails with a cryptic EPERM retry stack. Capture the install output and, on that lock signature, print a plain "quit all VS Code windows and re-run" banner and leave the built .vsix in place for a retry. Other failures still surface non-zero. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent f3e9e22 commit aee4ac0

1 file changed

Lines changed: 29 additions & 1 deletion

File tree

scripts/dogfood-vscode.mjs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,39 @@ function run(command, { ignoreFailure = false, stdio = 'inherit', env = process.
2121
return result;
2222
}
2323

24+
// Install the packaged VSIX. VS Code installs by renaming the extension folder,
25+
// and on Windows a running VS Code instance keeps the current extension's native
26+
// modules (node-pty) loaded, locking that folder — so the rename fails with EPERM
27+
// and a cryptic retry/stack trace. Capture the output and, on that lock, print a
28+
// plain "close VS Code and retry" instead of the raw error.
29+
function installVsix() {
30+
const result = spawnSync('code --install-extension dormouse.vsix --force', {
31+
cwd: extDir,
32+
shell: true,
33+
env: codeEnv,
34+
encoding: 'utf8',
35+
});
36+
process.stdout.write(result.stdout ?? '');
37+
process.stderr.write(result.stderr ?? '');
38+
if (result.status === 0) return;
39+
40+
const output = `${result.stdout ?? ''}${result.stderr ?? ''}`;
41+
if (/EPERM|operation not permitted|restart VS ?Code/i.test(output)) {
42+
console.error('\n──────────────────────────────────────────────────────────────');
43+
console.error("Couldn't install: VS Code is holding the old Dormouse extension");
44+
console.error('files open (its node-pty native modules lock the extension dir).');
45+
console.error('→ Quit ALL VS Code windows, then re-run `pnpm dogfood:vscode`.');
46+
console.error(' The .vsix is already built at vscode-ext/dormouse.vsix.');
47+
console.error('──────────────────────────────────────────────────────────────');
48+
}
49+
process.exit(result.status ?? 1);
50+
}
51+
2452
// Remove the legacy extension if present; ignore failure when it isn't installed.
2553
run('code --uninstall-extension diffplug.mouseterm', { ignoreFailure: true, stdio: 'ignore', env: codeEnv });
2654

2755
run('pnpm package');
28-
run('code --install-extension dormouse.vsix --force', { env: codeEnv });
56+
installVsix();
2957

3058
rmSync(vsix, { force: true });
3159

0 commit comments

Comments
 (0)