Let macOS apps with a non-ASCII APP_NAME launch - #148
Open
simonhamp wants to merge 1 commit into
Open
Conversation
electron-builder NFD-normalises every name it writes to disk on macOS - the .app bundle, the executable and each of the Electron helper apps - but writes CFBundleName straight from the product name, which reaches it composed (NFC). Electron finds its helper apps by appending " Helper (GPU).app" and friends to CFBundleName, so the two forms have to agree. For APP_NAME=MUNĖ they don't: the app traps on launch before it can spawn a single child process. ASCII names are identical in both forms, which is why this has gone unnoticed. Decompose the name ourselves in mac.extendInfo, which electron-builder merges over the Info.plist after writing it. productName is left composed, so Windows and Linux are untouched, and NFD is a no-op on ASCII, so nothing changes for existing apps. Fixes #98 Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YLMT7W3hSqRwX9gpZM5pXr
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.
Fixes #98.
Setting
APP_NAMEto something non-ASCII — the issue reportsMUNĖ— builds fine but produces a macOS app that never opens a window and spawns no child processes at all.Root cause
Not quite what the issue guessed.
app-builder-lib'sMacPackager.prepareAppInfo()constructsAppInfowithnormalizeNfd = true, so every name electron-builder writes to disk is NFD-decomposed:.appbundle and its executable, fromproductFilename<name> Helper (GPU).appand friends — whichelectronMac.jsnames fromsanitizedProductName, with a comment noting that Electron resolves helpers viaCFBundleNameBut
applyCommonInfo()writesCFBundleNameandCFBundleDisplayNamefrom the rawappInfo.productName, which arrives from the environment composed (NFC).So the bundle gets
MUNĖ Helper (GPU).appon disk whileCFBundleNameisMUNĖ. Electron can't line the two up and dies during startup, before it spawns anything. For ASCII names NFC and NFD are byte-identical, which is why this has gone unnoticed.Worth noting the dead end, since it's the intuitive one: APFS is normalisation-insensitive, so
fs.existsSync()on the NFC path does find the NFD directory. The failure isn't a filesystem lookup.Evidence
Reproduced with a bare Electron app on the versions we pin (electron 40, electron-builder 26):
productName: 'MUNE'productName: 'MUNĖ'EXC_BREAKPOINT) immediately, no children, no stderrMUNĖwithCFBundleNamerewritten to NFDMUNĖre-signed, plist untouched (control)The last row rules out code signing as the cause, and the third row is the fix, verified straight out of electron-builder with no post-processing.
The change
mac.extendInfonow setsCFBundleNameandCFBundleDisplayNameto the NFD form of the app name.extendInfois merged over the plist afterapplyCommonInfowrites it, so it wins.productNameitself is left composed, so Windows and Linux are untouched.null/undefinedplist values, so an unsetNATIVEPHP_APP_NAMEwould otherwise deleteCFBundleNamefrom the bundle entirely.Five tests cover it; two of them fail with the fix backed out.
Not addressed
Only macOS was investigated. On Linux
executableNameisn't set, so it defaults to the product name and a non-ASCII binary would land in/opt— untested, and no breakage reported there. Windows already setswin.executableNamefrom the slugged filename.This is arguably an electron-builder bug — it normalises the names on disk but not the plist key that indexes them — so an upstream issue may be worth filing alongside this workaround.
🤖 Generated with Claude Code
https://claude.ai/code/session_01YLMT7W3hSqRwX9gpZM5pXr