Skip to content

Commit f4a62a7

Browse files
authored
ensure tmp zdotdir exists (#246638)
1 parent 4949701 commit f4a62a7

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/vs/platform/terminal/node/terminalEnvironment.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { IShellLaunchConfig, ITerminalEnvironment, ITerminalProcessOptions } fro
1515
import { EnvironmentVariableMutatorType } from '../common/environmentVariable.js';
1616
import { deserializeEnvironmentVariableCollections } from '../common/environmentVariableShared.js';
1717
import { MergedEnvironmentVariableCollection } from '../common/environmentVariableCollection.js';
18-
import { chmod, realpathSync } from 'fs';
18+
import { chmod, realpathSync, mkdirSync } from 'fs';
1919
import { promisify } from 'util';
2020

2121
export function getWindowsBuildNumber(): number {
@@ -232,6 +232,21 @@ export async function getShellIntegrationInjection(
232232
const chmodAsync = promisify(chmod);
233233
await chmodAsync(zdotdir, 0o1700);
234234
} catch (err) {
235+
if (err.message.includes('ENOENT')) {
236+
try {
237+
mkdirSync(zdotdir);
238+
} catch (err) {
239+
logService.error(`Failed to create zdotdir at ${zdotdir}: ${err}`);
240+
return undefined;
241+
}
242+
try {
243+
const chmodAsync = promisify(chmod);
244+
await chmodAsync(zdotdir, 0o1700);
245+
} catch {
246+
logService.error(`Failed to set sticky bit on ${zdotdir}: ${err}`);
247+
return undefined;
248+
}
249+
}
235250
logService.error(`Failed to set sticky bit on ${zdotdir}: ${err}`);
236251
return undefined;
237252
}

0 commit comments

Comments
 (0)