Skip to content

Fix Windows/VSCode Electron startup issues#47

Open
Jeffrey0117 wants to merge 1 commit intoyan5xu:mainfrom
Jeffrey0117:fix/windows-electron-startup
Open

Fix Windows/VSCode Electron startup issues#47
Jeffrey0117 wants to merge 1 commit intoyan5xu:mainfrom
Jeffrey0117:fix/windows-electron-startup

Conversation

@Jeffrey0117
Copy link
Copy Markdown

@Jeffrey0117 Jeffrey0117 commented Jan 9, 2026

Problems Fixed:

  1. ELECTRON_RUN_AS_NODE environment variable conflict

    • When running from VSCode/Cursor (Electron-based IDEs), ELECTRON_RUN_AS_NODE=1 is inherited
    • This causes require('electron') to return a path string instead of the API object
    • Added start-electron.js script that clears this env var before spawning Electron
  2. Electron initialization timing issues

    • app.getPath() was called before app ready in LogManager
    • ipcMain.handle was called before app ready in IPCHandlers
    • Moved these initializations to after app.whenReady()
  3. Windows Python virtual environment path

    • Added .venv/Scripts/python.exe path for Windows (was only checking .venv/bin/python)

Files Changed:

  • start-electron.js (new) - Electron launcher that clears problematic env vars
  • package.json - Updated dev:main script to use new launcher
  • main.js - Moved IPC and env var init to app.whenReady()
  • src/helpers/logManager.js - Added lazy initialization for Electron APIs
  • src/helpers/funasrManager.js - Added Windows venv path support

## Problems Fixed:

1. **ELECTRON_RUN_AS_NODE environment variable conflict**
   - When running from VSCode/Cursor (Electron-based IDEs), `ELECTRON_RUN_AS_NODE=1` is inherited
   - This causes `require('electron')` to return a path string instead of the API object
   - Added `start-electron.js` script that clears this env var before spawning Electron

2. **Electron initialization timing issues**
   - `app.getPath()` was called before app ready in LogManager
   - `ipcMain.handle` was called before app ready in IPCHandlers
   - Moved these initializations to after `app.whenReady()`

3. **Windows Python virtual environment path**
   - Added `.venv/Scripts/python.exe` path for Windows (was only checking `.venv/bin/python`)

## Files Changed:
- `start-electron.js` (new) - Electron launcher that clears problematic env vars
- `package.json` - Updated dev:main script to use new launcher
- `main.js` - Moved IPC and env var init to app.whenReady()
- `src/helpers/logManager.js` - Added lazy initialization for Electron APIs
- `src/helpers/funasrManager.js` - Added Windows venv path support

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
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