@@ -30,11 +30,21 @@ let seq = 0
|
||||
* `npm_config_prefix` (e.g. "/opt/homebrew") into the child shell, which makes
|
||||
* nvm refuse to load ("nvm is not compatible with the npm_config_prefix
|
||||
* environment variable"). Strip it so the user's shell init runs cleanly.
|
||||
*
|
||||
* A macOS app launched from Spotlight/Finder (launchd GUI context) inherits NO
|
||||
* `LANG`/`LC_*`, so the child shell falls back to the `C`/POSIX locale — not
|
||||
* UTF-8. Anything multibyte the shell or `claude` emits then renders as high-byte
|
||||
* mojibake in xterm. Launching from a terminal (`npm run dev`) inherits the
|
||||
* terminal's UTF-8 locale, which is why dev looks fine and the packaged app does
|
||||
* not. Default a UTF-8 locale when none is set so both paths match.
|
||||
*/
|
||||
function ptyEnv(): { [key: string]: string } {
|
||||
const env = { ...process.env } as { [key: string]: string }
|
||||
delete env.npm_config_prefix
|
||||
delete env.npm_config_globalconfig
|
||||
if (process.platform !== 'win32' && !env.LC_ALL && !env.LC_CTYPE && !env.LANG) {
|
||||
env.LANG = 'en_US.UTF-8'
|
||||
}
|
||||
return env
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user