fix(code): make postinstall cross-platform#3404
Open
trippyogi wants to merge 2 commits into
Open
Conversation
Replace the Bash Electron postinstall with a Node script so pnpm install works on Windows without WSL or Git Bash. Document the remaining phrocs/dev workaround separately.
|
Merging to
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Replaces the Code app's Bash-based postinstall script with a cross-platform Node implementation so
pnpm installworks on Windows without WSL or Git Bash.The new script preserves the existing postinstall behavior:
better-sqlite3against Electron's ABInode-ptyspawn-helper execute bit on POSIX systemsIt 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 whenprocess.platform === "darwin". Intentional correction, not a regression.Why
On a fresh Windows 11 checkout,
pnpm installcurrently invokes:Windows may resolve
bashto the System32 WSL launcher even when no WSL distribution is installed, causing installation to fail with: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 devcommand still depends on phrocs, for which no Windows binary is currently published. Docs now recommend:pnpm dev:agentandpnpm dev:codein separate terminalspnpm dev:mprocsPartially 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.mjscompletes on an existing checkout (rebuildsbetter-sqlite3for Electron, downloads/skips agent binaries) without Git Bash / WSLapps/codepostinstallscript points atnode scripts/postinstall.mjspnpm lintexits 0 (pre-existing warnings elsewhere)pnpm typecheckalready fails on tip ofupstream/mainin@posthog/agent(unrelated to this change)node_modules, thenpnpm install(exit 0 in ~2m).PATHstill prefersC:\Windows\System32\bash.exe(WSL stub); postinstall rannode scripts/postinstall.mjsand never invoked bashElectron binary missing at .../electron/dist — downloading...), then sqlite rebuild + binary download; postinstall completedTest plan
pnpm installafter wipingnode_modules, without relying on Git Bash/WSLpnpm installon an already-installed treepnpm installstill applies development Electron display namepnpm installstill rebuilds native modules and downloads binariespnpm dev/ phrocs remains unchanged (out of scope)