@@ -254,6 +254,7 @@ const runCommandOutput = Effect.fn("desktop.shellEnvironment.runCommandOutput")(
254254 readonly probe : DesktopShellEnvironmentProbe ;
255255 readonly command : string ;
256256 readonly args : ReadonlyArray < string > ;
257+ readonly env : NodeJS . ProcessEnv ;
257258 readonly timeout : Duration . Duration ;
258259 readonly shell ?: boolean ;
259260} ) : Effect . fn . Return < string , never , ChildProcessSpawner . ChildProcessSpawner > {
@@ -263,6 +264,8 @@ const runCommandOutput = Effect.fn("desktop.shellEnvironment.runCommandOutput")(
263264 const child = yield * spawner . spawn (
264265 ChildProcess . make ( input . command , input . args , {
265266 shell : input . shell ?? false ,
267+ env : input . env ,
268+ extendEnv : false ,
266269 stdin : "ignore" ,
267270 stdout : "pipe" ,
268271 stderr : "ignore" ,
@@ -318,27 +321,32 @@ const runCommandOutput = Effect.fn("desktop.shellEnvironment.runCommandOutput")(
318321const readLoginShellEnvironment = (
319322 shell : string ,
320323 names : ReadonlyArray < string > ,
324+ env : NodeJS . ProcessEnv ,
321325) : Effect . Effect < EnvironmentPatch , never , ChildProcessSpawner . ChildProcessSpawner > =>
322326 names . length === 0
323327 ? Effect . succeed ( { } )
324328 : runCommandOutput ( {
325329 probe : "login-shell" ,
326330 command : shell ,
327331 args : [ "-ilc" , buildEnvironmentCaptureCommand ( shell , names ) ] ,
332+ env,
328333 timeout : LOGIN_SHELL_TIMEOUT ,
329334 } ) . pipe ( Effect . map ( ( output ) => extractEnvironment ( output , names ) ) ) ;
330335
331- const readLaunchctlPath = runCommandOutput ( {
332- probe : "launchctl-path" ,
333- command : "/bin/launchctl" ,
334- args : [ "getenv" , "PATH" ] ,
335- timeout : LAUNCHCTL_TIMEOUT ,
336- } ) . pipe ( Effect . map ( trimNonEmpty ) ) ;
336+ const readLaunchctlPath = ( env : NodeJS . ProcessEnv ) =>
337+ runCommandOutput ( {
338+ env,
339+ probe : "launchctl-path" ,
340+ command : "/bin/launchctl" ,
341+ args : [ "getenv" , "PATH" ] ,
342+ timeout : LAUNCHCTL_TIMEOUT ,
343+ } ) . pipe ( Effect . map ( trimNonEmpty ) ) ;
337344
338345const readWindowsEnvironment = Effect . fn ( "desktop.shellEnvironment.readWindowsEnvironment" ) (
339346 function * (
340347 names : ReadonlyArray < string > ,
341348 options : WindowsProbeOptions ,
349+ env : NodeJS . ProcessEnv ,
342350 ) : Effect . fn . Return < EnvironmentPatch , never , ChildProcessSpawner . ChildProcessSpawner > {
343351 if ( names . length === 0 ) return { } ;
344352
@@ -355,6 +363,7 @@ const readWindowsEnvironment = Effect.fn("desktop.shellEnvironment.readWindowsEn
355363 probe : options . loadProfile ? "powershell-profile" : "powershell-no-profile" ,
356364 command,
357365 args,
366+ env,
358367 timeout : LOGIN_SHELL_TIMEOUT ,
359368 } ) ;
360369 const environment = extractEnvironment ( output , names ) ;
@@ -373,8 +382,8 @@ const installWindowsEnvironment = Effect.fn("desktop.shellEnvironment.installWin
373382 ) : Effect . fn . Return < boolean , never , ChildProcessSpawner . ChildProcessSpawner > {
374383 const [ noProfile , profile ] = yield * Effect . all (
375384 [
376- readWindowsEnvironment ( [ "PATH" ] , { loadProfile : false } ) ,
377- readWindowsEnvironment ( WINDOWS_PROFILE_ENV_NAMES , { loadProfile : true } ) ,
385+ readWindowsEnvironment ( [ "PATH" ] , { loadProfile : false } , config . env ) ,
386+ readWindowsEnvironment ( WINDOWS_PROFILE_ENV_NAMES , { loadProfile : true } , config . env ) ,
378387 ] ,
379388 { concurrency : 2 } ,
380389 ) ;
@@ -412,14 +421,14 @@ const installPosixEnvironment = Effect.fn("desktop.shellEnvironment.installPosix
412421 for ( const shell of listLoginShellCandidates ( config . platform , config . env . SHELL ) ) {
413422 Object . assign (
414423 shellEnvironment ,
415- yield * readLoginShellEnvironment ( shell , LOGIN_SHELL_ENV_NAMES ) ,
424+ yield * readLoginShellEnvironment ( shell , LOGIN_SHELL_ENV_NAMES , config . env ) ,
416425 ) ;
417426 if ( shellEnvironment . PATH ) break ;
418427 }
419428
420429 const launchctlPath =
421430 config . platform === "darwin" && ! shellEnvironment . PATH
422- ? yield * readLaunchctlPath
431+ ? yield * readLaunchctlPath ( config . env )
423432 : Option . none < string > ( ) ;
424433 const mergedPath = mergePaths ( config . platform , [
425434 trimNonEmpty ( shellEnvironment . PATH ) . pipe ( Option . orElse ( ( ) => launchctlPath ) ) ,
0 commit comments