From 245979fbb9ae3c27eefef9777c16b8da5dd00d04 Mon Sep 17 00:00:00 2001 From: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com> Date: Mon, 17 Feb 2025 21:31:30 -0800 Subject: [PATCH] Fix reading `JUPYTER_RUNTIME_DIR` and `XDG_RUNTIME_DIR` (#16451) Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com> --- src/kernels/raw/finder/jupyterPaths.node.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/kernels/raw/finder/jupyterPaths.node.ts b/src/kernels/raw/finder/jupyterPaths.node.ts index 29e1b8ff144..e9d7d41d63b 100644 --- a/src/kernels/raw/finder/jupyterPaths.node.ts +++ b/src/kernels/raw/finder/jupyterPaths.node.ts @@ -133,7 +133,9 @@ export class JupyterPaths { private async getRuntimeDirImpl(): Promise { let runtimeDir: Uri | undefined; const userHomeDir = this.platformService.homeDir; - if (userHomeDir) { + if (process.env['JUPYTER_RUNTIME_DIR']) { + runtimeDir = Uri.file(path.normalize(process.env['JUPYTER_RUNTIME_DIR'])); + } else if (userHomeDir) { if (this.platformService.isWindows) { // On windows the path is not correct if we combine those variables. // It won't point to a path that you can actually read from. @@ -141,8 +143,8 @@ export class JupyterPaths { } else if (this.platformService.isMac) { runtimeDir = uriPath.joinPath(userHomeDir, macJupyterRuntimePath); } else { - runtimeDir = process.env['$XDG_RUNTIME_DIR'] - ? Uri.file(path.join(process.env['$XDG_RUNTIME_DIR'], 'jupyter', 'runtime')) + runtimeDir = process.env['XDG_RUNTIME_DIR'] + ? Uri.file(path.join(process.env['XDG_RUNTIME_DIR'], 'jupyter', 'runtime')) : uriPath.joinPath(userHomeDir, '.local', 'share', 'jupyter', 'runtime'); } }