Skip to content

fix: resolve rcedit path at runtime to fix ENOENT on Windows#330

Open
Dyn4sty wants to merge 1 commit intoblackboardsh:mainfrom
Dyn4sty:fix/rcedit-hardcoded-path
Open

fix: resolve rcedit path at runtime to fix ENOENT on Windows#330
Dyn4sty wants to merge 1 commit intoblackboardsh:mainfrom
Dyn4sty:fix/rcedit-hardcoded-path

Conversation

@Dyn4sty
Copy link
Copy Markdown

@Dyn4sty Dyn4sty commented Mar 20, 2026

Problem

When electrobun dev or electrobun build runs on Windows and the project has a Windows icon configured, icon embedding into launcher.exe, bun.exe, and the installer EXE silently fails with:

Warning: Failed to embed icon into launcher.exe: Error: Error executing command (D:\a\electrobun\electrobun\package\node_modules\rcedit\bin\rcedit-x64.exe ...):
spawn D:\a\electrobun\electrobun\package\node_modules\rcedit\bin\rcedit-x64.exe ENOENT
The system cannot find the drive specified.

Root cause: The CLI binary is compiled with bun build --compile on the GitHub Actions runner whose workspace is D:\a\electrobun\. Bun's compiler freezes __dirname (inside the bundled rcedit CJS module) to that build-machine path. On any developer machine without a D:\ drive, path.resolve(__dirname, '..', 'bin', 'rcedit-x64.exe') resolves to a non-existent path.

Fix

Replace all three await import("rcedit") call sites with a new spawnRcedit() helper that resolves the rcedit-x64.exe path at runtime using process.execPath:

dirname(process.execPath)/../../rcedit/bin/rcedit-x64.exe

Since electrobun.exe and rcedit are always sibling packages in the consuming project's node_modules/, this path is correct at runtime on any machine, regardless of where the binary was compiled.

Affected call sites

  • Icon embedding into launcher.exe (~line 2166)
  • Icon embedding into bun.exe (~line 2263)
  • Icon embedding into the Windows installer EXE (~line 4310)

Testing

Verified by reproducing the ENOENT locally (no D:\ drive) and confirming all three call sites now correctly resolve to the local node_modules/rcedit/bin/rcedit-x64.exe.

When the CLI is compiled with `bun build --compile`, dynamic
`import("rcedit")` freezes __dirname to the *build-machine* path
(e.g. D:\a\electrobun\... on the GitHub Actions runner) rather than
the runtime machine's path. On any developer machine without a D:\
drive, this causes:

    spawn D:\a\electrobun\...\rcedit-x64.exe ENOENT
    The system cannot find the drive specified.

Fix: replace all three `await import("rcedit")` call sites with a new
`spawnRcedit()` helper that locates rcedit-x64.exe at runtime using
`process.execPath`. Since electrobun.exe and rcedit are always sibling
packages in the consuming project's node_modules, we resolve:

    dirname(process.execPath)/../../rcedit/bin/rcedit-x64.exe

This is always correct at runtime regardless of where the CLI binary
was originally compiled.

Fixes icon embedding for launcher.exe, bun.exe, and the Windows
installer EXE on machines whose drive layout differs from the CI runner.

Made-with: Cursor
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