Skip to content

fix(code): make postinstall cross-platform#3403

Closed
trippyogi wants to merge 2 commits into
PostHog:mainfrom
trippyogi:fix/windows-dev-setup
Closed

fix(code): make postinstall cross-platform#3403
trippyogi wants to merge 2 commits into
PostHog:mainfrom
trippyogi:fix/windows-dev-setup

Conversation

@trippyogi

Copy link
Copy Markdown

Summary

Replaces the Code app's Bash-based postinstall script with a cross-platform Node implementation so pnpm install works on Windows without WSL or Git Bash.

The new script preserves the existing postinstall behavior:

  • repairs a missing Electron distribution
  • rebuilds better-sqlite3 against Electron's ABI
  • restores the node-pty spawn-helper execute bit on POSIX systems
  • patches the Electron development app name on macOS
  • downloads the bundled agent binaries

It also adds Windows development notes and troubleshooting guidance.

Behavior note: the old shell script always invoked patch-electron-name.sh, which then no-oped when the macOS plist was absent. The Node script only invokes it when process.platform === darwin. Intentional correction, not a regression.

Why

On a fresh Windows 11 checkout, pnpm install currently invokes:

bash scripts/postinstall.sh

Windows may resolve bash to the System32 WSL launcher even when no WSL distribution is installed, causing installation to fail with:

execvpe(/bin/bash) failed: No such file or directory

Most of the postinstall workflow already invokes Node scripts, so moving the orchestration itself to Node removes the unnecessary shell dependency.

Scope

This addresses the installation failure from #3252.

The default pnpm dev command still depends on phrocs, for which no Windows binary is currently published. Docs now recommend:

  • Prefer: pnpm dev:agent and pnpm dev:code in separate terminals
  • Alternative: pnpm dev:mprocs

Partially addresses #3252. Leaving the issue open for the remaining pnpm dev / phrocs Windows work unless maintainers decide the documented workaround is enough.

Validation

Tested on Windows 11 (build 26200), Node 22.12.0, pnpm 10.23.0:

  • node apps/code/scripts/postinstall.mjs completes on an existing checkout (rebuilds better-sqlite3 for Electron, downloads/skips agent binaries) without Git Bash / WSL
  • apps/code postinstall script points at node scripts/postinstall.mjs
  • Biome/syntax check on postinstall.mjs
  • Prior to this PR (with Bash workarounds only): full workspace build and packaged win-unpacked app launch — confirms Windows toolchain beyond postinstall; not re-run as a clean clone against this Node postinstall in this PR session
  • Clean rm -rf node_modules && pnpm install from a fresh clone on this branch
  • Explicit empty/electron/dist missing self-heal on this branch
  • Packaged Windows app rebuilt against this branch
  • macOS postinstall locally (expects CI / maintainer smoke)
  • Linux postinstall locally (expects CI / maintainer smoke)

Test plan

  • Fresh Windows clone: pnpm install without WSL/Git Bash
  • Re-run pnpm install on an already-installed tree
  • macOS: pnpm install still applies development Electron display name
  • Linux: pnpm install still rebuilds native modules and downloads binaries
  • Confirm pnpm dev / phrocs remains unchanged (out of scope)

trippyogi and others added 2 commits July 13, 2026 12:14
Replace bash postinstall with a Node script so pnpm install no longer hits the WSL bash stub, and document the Windows setup gap for phrocs.

Co-authored-by: Cursor <cursoragent@cursor.com>
Prefer the two-terminal dev workaround wording and shorten the Electron dist-repair comment.

Co-authored-by: Cursor <cursoragent@cursor.com>
@trunk-io

trunk-io Bot commented Jul 13, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@trippyogi trippyogi closed this Jul 13, 2026
@trippyogi trippyogi deleted the fix/windows-dev-setup branch July 13, 2026 19:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant