File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change 55*
66*/
77
8- import { warning } from "log/mod.ts" ;
8+ import { debug , warning } from "log/mod.ts" ;
99import { join } from "path/mod.ts" ;
10- import { ensureDirSync } from "fs/mod.ts" ;
10+ import { ensureDirSync , existsSync } from "fs/mod.ts" ;
1111import { removeIfExists , safeRemoveIfExists } from "./path.ts" ;
1212import { TempContext } from "./temp-types.ts" ;
1313
@@ -18,6 +18,21 @@ let tempDir: string | undefined;
1818let tempContext : TempContext | undefined ;
1919
2020export function initSessionTempDir ( ) {
21+ // if TMPDIR exists and has been removed (sometimes occurs for stale TMPDIR values
22+ // in resurrected RStudio terminal sessions) then try to re-create it
23+ const tmpEnv = Deno . env . get ( "TMPDIR" ) ;
24+ if ( tmpEnv ) {
25+ try {
26+ if ( ! existsSync ( tmpEnv ) ) {
27+ ensureDirSync ( tmpEnv ) ;
28+ }
29+ } catch ( err ) {
30+ if ( err . message ) {
31+ debug ( "Error attempting to create TMPDIR: " + err . message ) ;
32+ }
33+ }
34+ }
35+
2136 tempDir = Deno . makeTempDirSync ( { prefix : "quarto-session" } ) ;
2237}
2338
You can’t perform that action at this time.
0 commit comments