File tree Expand file tree Collapse file tree 1 file changed +21
-2
lines changed
src/vs/workbench/contrib/terminal/electron-browser Expand file tree Collapse file tree 1 file changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -98,10 +98,29 @@ export class TerminalInstanceService implements ITerminalInstanceService {
98
98
this . _mainProcessParentEnv = env ;
99
99
}
100
100
101
- // For macOS just return the root environment which seems to always be {}, this is the
102
- // parent of the main process when code is launched from the dock.
101
+ // For macOS it doesn't appear to be possible to get the "root" environment as
102
+ // `ps eww -o command` for PID 1 (the parent of the main process when launched from the
103
+ // dock/finder) returns no environment, because of this we will fill in the root environment
104
+ // using a whitelist of environment variables that we have.
103
105
if ( isMacintosh ) {
104
106
this . _mainProcessParentEnv = { } ;
107
+ // This list was generated by diffing launching a terminal with {} and the system
108
+ // terminal launched from finder.
109
+ const rootEnvVars = [
110
+ 'SHELL' ,
111
+ 'SSH_AUTH_SOCK' ,
112
+ 'Apple_PubSub_Socket_Render' ,
113
+ 'XPC_FLAGS' ,
114
+ 'XPC_SERVICE_NAME' ,
115
+ 'HOME' ,
116
+ 'LOGNAME' ,
117
+ 'TMPDIR'
118
+ ] ;
119
+ rootEnvVars . forEach ( k => {
120
+ if ( process . env [ k ] ) {
121
+ this . _mainProcessParentEnv ! [ k ] = process . env [ k ] ! ;
122
+ }
123
+ } ) ;
105
124
}
106
125
107
126
// TODO: Windows should return a fresh environment block, might need native code?
You can’t perform that action at this time.
0 commit comments