@@ -467,9 +467,6 @@ const installPosixEnvironment = Effect.fn("desktop.shellEnvironment.installPosix
467467 "HOMEBREW_PREFIX" ,
468468 "HOMEBREW_CELLAR" ,
469469 "HOMEBREW_REPOSITORY" ,
470- "LANG" ,
471- "LC_ALL" ,
472- "LC_CTYPE" ,
473470 "XDG_CONFIG_HOME" ,
474471 "XDG_DATA_HOME" ,
475472 "XDG_RUNTIME_DIR" ,
@@ -480,16 +477,27 @@ const installPosixEnvironment = Effect.fn("desktop.shellEnvironment.installPosix
480477 }
481478 }
482479
483- // GUI launches inherit no locale from launchd, so spawned agents land in the C
484- // locale and pbcopy decodes their UTF-8 output as MacRoman. Older supported
485- // macOS releases do not provide C.UTF-8, so set only LC_CTYPE to a UTF-8 locale
486- // available on those releases. Leaving LANG unset keeps C-stable collation and
487- // formatting, so output parsing is unaffected.
480+ // Locale variables form one precedence group: LC_ALL can override an inherited
481+ // LANG or LC_CTYPE, so only hydrate the group when the process has none of them.
488482 if (
489483 config . platform === "darwin" &&
490484 LOCALE_ENV_NAMES . every ( ( name ) => Option . isNone ( trimNonEmpty ( config . env [ name ] ) ) )
491485 ) {
492- config . env . LC_CTYPE = FALLBACK_LC_CTYPE ;
486+ for ( const name of LOCALE_ENV_NAMES ) {
487+ const value = trimNonEmpty ( shellEnvironment [ name ] ) ;
488+ if ( Option . isSome ( value ) ) {
489+ config . env [ name ] = value . value ;
490+ }
491+ }
492+
493+ // GUI launches inherit no locale from launchd, so spawned agents land in the C
494+ // locale and pbcopy decodes their UTF-8 output as MacRoman. Older supported
495+ // macOS releases do not provide C.UTF-8, so set only LC_CTYPE to a UTF-8 locale
496+ // available on those releases. Leaving LANG unset keeps C-stable collation and
497+ // formatting, so output parsing is unaffected.
498+ if ( LOCALE_ENV_NAMES . every ( ( name ) => Option . isNone ( trimNonEmpty ( config . env [ name ] ) ) ) ) {
499+ config . env . LC_CTYPE = FALLBACK_LC_CTYPE ;
500+ }
493501 }
494502
495503 if (
0 commit comments