From f6aced8a84ccf4ad450e188a176e52fa83432645 Mon Sep 17 00:00:00 2001 From: Mehmet Bektas Date: Wed, 16 Aug 2023 20:07:35 -0700 Subject: [PATCH 1/2] fix conda sub env activation issue --- src/main/server.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/server.ts b/src/main/server.ts index 7eb79e2d..a9527459 100644 --- a/src/main/server.ts +++ b/src/main/server.ts @@ -12,7 +12,6 @@ import { createTempFile, getEnvironmentPath, getFreePort, - getSchemasDir, getUserDataDir, waitForDuration } from './utils'; @@ -32,7 +31,6 @@ const SERVER_RESTART_LIMIT = 3; // max server restarts function createLaunchScript( serverInfo: JupyterServer.IInfo, baseCondaPath: string, - schemasDir: string, port: number, token: string ): string { @@ -71,6 +69,7 @@ function createLaunchScript( // conda-packed environments let condaActivatePath = ''; + let condaShellScriptPath = ''; let isBaseCondaActivate = true; // use activate from the environment instead of base when possible @@ -94,6 +93,12 @@ function createLaunchScript( isBaseCondaActivate = false; } else { condaActivatePath = path.join(baseCondaPath, 'bin', 'activate'); + condaShellScriptPath = path.join( + baseCondaPath, + 'etc', + 'profile.d', + 'conda.sh' + ); } } } @@ -113,7 +118,11 @@ function createLaunchScript( if (isConda) { script = ` source "${condaActivatePath}" - ${isBaseCondaActivate ? `conda activate "${envPath}"` : ''} + ${ + isBaseCondaActivate + ? `source ${condaShellScriptPath} && conda activate "${envPath}"` + : '' + } ${launchCmd}`; } else { script = ` @@ -264,7 +273,6 @@ export class JupyterServer { const launchScriptPath = createLaunchScript( this._info, baseCondaPath, - getSchemasDir(), this._info.port, this._info.token ); From b575cae2b8fb31c3eefdca54b325bb794a2dc13e Mon Sep 17 00:00:00 2001 From: Mehmet Bektas Date: Thu, 17 Aug 2023 07:31:47 -0700 Subject: [PATCH 2/2] fix venv activation on Windows --- src/main/server.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/server.ts b/src/main/server.ts index a9527459..fcfde8fb 100644 --- a/src/main/server.ts +++ b/src/main/server.ts @@ -9,6 +9,7 @@ import { request as httpRequest } from 'http'; import { request as httpsRequest } from 'https'; import { IDisposable, IEnvironmentType, IPythonEnvironment } from './tokens'; import { + activatePathForEnvPath, createTempFile, getEnvironmentPath, getFreePort, @@ -103,6 +104,8 @@ function createLaunchScript( } } + const envActivatePath = activatePathForEnvPath(envPath); + if (isWin) { if (isConda) { script = ` @@ -111,7 +114,7 @@ function createLaunchScript( CALL ${launchCmd}`; } else { script = ` - CALL ${envPath}\\activate.bat + CALL ${envActivatePath} CALL ${launchCmd}`; } } else { @@ -126,7 +129,7 @@ function createLaunchScript( ${launchCmd}`; } else { script = ` - source "${envPath}/bin/activate" + source "${envActivatePath}" ${launchCmd}`; } }